Extract Class

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
(New page: This is a common refactoring method, given this moniker in Martin Fowler's Refactoring book. When a class gets larger and more complex, we can manage this complexity by breaking ...)
 
m (Reverted edits by Ebybymic (Talk); changed back to last version by RobertLechte)
 
(One intermediate revision by one user not shown)

Latest revision as of 03:18, 25 November 2010

This is a common refactoring method, given this moniker in Martin Fowler's Refactoring book.

When a class gets larger and more complex, we can manage this complexity by breaking the large class into multiple smaller classes. As an Example, mapping software may contain Country objects. If the map simply stores the name of the country, its population, and the name of its capital city, then the class is small and manageable. However if the class is expanded to store a larger amount of information, the class will become unwieldy.

If for example we wish to store multiple historical population figures for each country, it's sensible to extract this information into a separate Population object. The provides separation of concerns, avoids the Divergent change smell, and keeps both objects small.

Personal tools