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.

Maxpm
  • 3,146
  • 1
  • 25
  • 34

2 Answers2

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.

Mike Partridge
  • 6,587
  • 1
  • 25
  • 39
3

Sounds like an extreme version of Modularization

this kind of obsessive refactoring is counterproductive.

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

knut
  • 1,398
  • 1
  • 10
  • 16