6
Developer's Corner / The Composed Method pattern
« on: October 28, 2010, 01:48 PM »
I've been a big fan of this and now I know the actual name for this style of coding. Anyone else find themselves doing this? I use to be a bit gun shy on creating so many methods but I truely find code a lot easier to read when the methods are broken down into simpler tasks and the names given to the methods are much more meaningful.
Composed Method pattern:
http://community.devexpress.com/blogs/ctodx/archive/2010/08/18/devexpress-newsletter-32-message-from-the-cto.aspx
http://tv.devexpress.com/#ComposedMethodPattern
Composed Method pattern:
The Composed Method pattern
One of the things I've adopted over the years in my own programming is the use of small methods -- that is, small as in few lines of code. It's made much easier by the use of a good Extract Method refactoring tool. In my case, that's CodeRush, and it's become second nature to apply Extract Method as I'm writing the code since there no cognitive friction in using it.
I was delighted to learn recently that this practice is known as the Composed Method pattern. It was first devised and promoted by Kent Beck in Smalltalk. In essence, there are three rules to the pattern:
1. Divide your programs into methods that only perform one identifiable task.
2. Keep all of the operations in a method at the same level of abstraction.
3. This will result in programs with many small methods, each a few lines long.
http://community.devexpress.com/blogs/ctodx/archive/2010/08/18/devexpress-newsletter-32-message-from-the-cto.aspx
http://tv.devexpress.com/#ComposedMethodPattern