How often should I make blocks of code into functions?

So when I’m typing code, sometimes there are blocks of code that I only use once but would make the code easier to read if they were put in a separate function. Should I make these into functions or leave them as normal code and just make the code reading more difficult?

1 Like

There is a arrow you can click next to the line number to hide sections of code.

If you are gonna use them more than once you should make it into a function. It depends on what the code does.

You should use functions when your repeating the code or to make it look better.

If there is some thing you will be doing more than once, I would put into a function. If your only doing it once, then I would just write it as code. Maybe add comments in your script to help you see what your doing.

1 Like

Honestly functions are very good if you want to debug a large script. Also, it gives flexibility as you can manipulate the parameters.

2 Likes

This is a pretty thoughtful take on this issue: John Carmack on Inlined Code

1 Like