Last Revision — April 19, 2022
1 Min Read
Lazy Class
Dispensables
Unnecessary Complexity
Between Classes
- Dubious Abstraction (family)
- Speculative Generality (caused)
- Primitive Obsession (antagonistic)
Martin Fowler in book (2018):
"Refactoring: Improving the Design of Existing Code (3rd Edition)"
Martin Fowler in book (1999):
"Refactoring: Improving the Design of Existing Code"
A Lazy Element is an element that does not do enough. If a method, variable, or class does not do enough to pay for itself (for increased complexity of the project), it should be combined into another entity.
This smell can happen due to the aggressive refactorization process in which the functionality of a class was truncated. It can also occur due to the unnecessary pre-planning - Speculative Generality - developer made it in anticipation of a future need that never eventuates.
Projects complexity increases with the number of entities.
class Strength:
value: int
class Person:
health: int
intelligence: int
strength: Strength
class Person:
health: int
intelligence: int
strength: int