Large class smell

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
(New page: ''Refactoring'' Martin Fowler 1999 states that: When a class is trying to do too much, it often shows up as too many instance variables. When a class has too many instance variables, d...)
 
Line 1: Line 1:
 +
"A class with too much code is prime breeding ground for duplicated code, chaos, and death." - ''Refactoring'' [[Martin Fowler 1999]]
 +
 
''Refactoring'' [[Martin Fowler 1999]] states that: When a class is trying to do too much, it often shows up as too many instance variables. When a class has too many instance variables, duplicated code cannot be far behind.
 
''Refactoring'' [[Martin Fowler 1999]] states that: When a class is trying to do too much, it often shows up as too many instance variables. When a class has too many instance variables, duplicated code cannot be far behind.
  
 
== Refactoring ==
 
== Refactoring ==
  
''Refactoring'' gives some suggestions on how a large class can be
+
''Refactoring'' gives some suggestions on how the Large class code smell can be remedied. You can use the [[Extract Class]] technique to group related variables into a new class. ''Refactoring'' recommends to: Choose variables to go together in the component (class) that makes sense for each. For example, "depositAmount" and "depositCurrency" are likely to belong together in a component (class).

Revision as of 03:01, 1 August 2008

"A class with too much code is prime breeding ground for duplicated code, chaos, and death." - Refactoring Martin Fowler 1999

Refactoring Martin Fowler 1999 states that: When a class is trying to do too much, it often shows up as too many instance variables. When a class has too many instance variables, duplicated code cannot be far behind.

Refactoring

Refactoring gives some suggestions on how the Large class code smell can be remedied. You can use the Extract Class technique to group related variables into a new class. Refactoring recommends to: Choose variables to go together in the component (class) that makes sense for each. For example, "depositAmount" and "depositCurrency" are likely to belong together in a component (class).

Personal tools