Temporary field smell
From CSSEMediaWiki
(Difference between revisions)
JaninaVoigt (Talk | contribs) (New page: This smell occurs when a class has a field that is only used some of the time. A class like this can be hard to understand because you would normally expect it to use all its instance vari...) |
m (→See also) |
||
(One intermediate revision by one user not shown) | |||
Line 2: | Line 2: | ||
This can for example happen when you have an algorithm that requires data structures for several methods and because you don't want to pass the data structures around as parameters you make them instance variables. However, they only have a valid value during the algorithm's execution. Instead, you should [[Extract Class]] to make a class containing the algorithm, the data structures and the methods that use the data structures. | This can for example happen when you have an algorithm that requires data structures for several methods and because you don't want to pass the data structures around as parameters you make them instance variables. However, they only have a valid value during the algorithm's execution. Instead, you should [[Extract Class]] to make a class containing the algorithm, the data structures and the methods that use the data structures. | ||
+ | |||
+ | == See also == | ||
+ | * [[Code smells]] | ||
+ | |||
+ | {{Template:CodeSmells}} | ||
+ | |||
+ | [[Category:Code smells]] |
Latest revision as of 09:32, 14 October 2009
This smell occurs when a class has a field that is only used some of the time. A class like this can be hard to understand because you would normally expect it to use all its instance variables and it can be difficult to see what the temporary variable is used for.
This can for example happen when you have an algorithm that requires data structures for several methods and because you don't want to pass the data structures around as parameters you make them instance variables. However, they only have a valid value during the algorithm's execution. Instead, you should Extract Class to make a class containing the algorithm, the data structures and the methods that use the data structures.
See also