2

I recall a methodology that emphasized making functions short and numerous. It said that if a section of code can be separated at all, it should be, even if the resultant functions are only used once. Some argue that it's DRY taken too far, and that this kind of obsessive refactoring is counterproductive.

Does anyone know what it could be called? I don't think it actually had refactoring in the name.

7
  • I would suggest that is a leaning towards developing best practices by following along the design principles of the Single Responsibility Principle and Don't Repeat yourself. Maybe a bit of KISS as well.
    – dreza
    Commented Jan 12, 2012 at 20:18
  • Code that is "modular" sometimes has the attributes you describe. Commented Jan 12, 2012 at 20:23
  • As an aside, this seems to come naturally out of literate programming.
    – Maxpm
    Commented Jan 12, 2012 at 20:27
  • It sounds more like Death by Spoon.
    – Mike Nakis
    Commented Jan 12, 2012 at 20:36
  • 1
    Structured Programming
    – Paul
    Commented Jan 12, 2012 at 21:05

2 Answers 2

10

Martin Fowler's Refactoring book identifies long methods as a code smell, with the Extract Method refactor being a solution.

I think it could also be considered a derivative of the Single Responsibility Principle. Applying it at the method level can make unit-testing much easier, since you don't have to worry about testing multiple results from a single tested method.

It could also be called Short Methods; the link has a good discussion of this methodology. The point is that we can only keep in our minds around 5-9 things at one time, so shorter methods allow us to abstract away some bit of logic whose implementation is unimportant at the point where it's used.

3

Sounds like an extreme version of Modularization

this kind of obsessive refactoring is counterproductive.

That's called "Modularize, not atomize" ;-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.