Large Class

Prev don't be afraid of buying books Next

Fowler and Beck [F] note that the presence of too many instance variables usually indicates that a class is trying to do too much. In general, large classes typically contain too many responsibilities. Extract Class [F] and Extract Subclass [F], which are some of the main refactorings used to address this smell, help move responsibilities to other classes. The pattern-directed refactorings in this book make use of these refactorings to reduce the size of classes.

Replace Conditional Dispatcher with Command (191) extracts behavior into Command [DP] classes, which can greatly reduce the size of a class that performs a variety of behaviors in response to different requests.

Replace State-Altering Conditionals with State (166) can reduce a large class filled with state transition code into a small class that delegates to a family of State [DP] classes.

Replace Implicit Language with Interpreter (269) can reduce a large class into a small one by transforming copious code for emulating a language into a small Interpreter [DP].


Refactoring to Patterns (The Addison-Wesley Signature Series)
Refactoring to Patterns
ISBN: 0321213351
EAN: 2147483647
Year: 2003
Pages: 103

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: