Best practices: Many small functions/methods, or bigger functions with logical process components inline? [closed]

I always break long methods up into logical chunks and try to make smaller methods out of them. I don’t normally turn a few lines into a separate method until I need it in two different places, but sometimes I do just to help readability, or if I want to test it in isolation.

Fowler’s Refactoring is all about this topic, and I highly recommend it.

Here’s a handy rule of thumb that I use from Refactoring. If a section of code has a comment that I could re-word into a method name, pull it out and make it a method.

Leave a Comment

tech