re: When do you create a function or method? VIEW POST

TOP OF THREAD FULL DISCUSSION
re: For me, it's about readability and DRYness (DRY = Don't Repeat Yourself). It doesn't always have to be something that will be called in more tha...
 

Great response!

Personally, I don't see repeating yourself that much of a problem. Sure, if there are 5-10 lines of code repeated across your code you should create a function and use that, but I also encountered the opposite, introducing problems by creating functions and using them everywhere.

The problem was the function itself. It was fairly short (less than 5 lines of code) and it was almost certain that it will be modified in the future, but not for all calls, only for some. That's where creating a function can bite you.

code of conduct - report abuse