Monday, August 10, 2009

Beany Classes and Busy Methods

You know you're in trouble in hardly more than a glance. All the methods are long and busy, and do their work data members of other classes... other classes without any behavior. Methods are placed in ersatz global functions. Why? Because that's where they're closest to the runtime. Perhaps in module initialization, perhaps one function call away from the "static main."

The solution for the code is well known. Extract method, move method, pull up method, red/green/refactor.

The real problem here is that we don't know enough about prevention. Why do we keep getting saddled with busy methods running roughshod all over beany classes? Is it laziness, poor education, a lack of good examples, a confused sense of practicality? The human problem is interesting enough that I need insight from a wide range of agilists.