When we see fields that always seem to be used together (e.g., passed together as mathod parameters, or used together in methods), this gives a strong indication that these fields really belong in their own class.
Jason Gorman illustrates how to refactor a data clump by extracting a class containing those fields and then moving the behaviour that accesses them into the new class.
Download the source code from http://bit.ly/c6nSIm
For training and coaching in refactoring, TDD and OO design, visit http://www.codemanship.com
Link to this comment:
All Comments (0)