Code Smell 13 - Empty Constructors
11 October, 2022
9
9
0
Contributors
TL;DR: Pass the essence to all your objects so they will not need to mutate.
Problems
•
Mutability
•
Incomplete objects
•
Concurrency inconsistencies between creation and essence setting.
•
Setters
Solutions
1.
Pass the object's essence on creation
2.
Create objects with their immutable essence.
Examples
•
Sample Code
Wrong
Right
Detection
Exceptions
•
More info
Tags
•
Essence
•
Incomplete
•
Mutable
Conclusion
Credits
In a purely functional program, the value of a [constant] never changes, and yet, it changes all the time! A paradox!
refactoring
cleancode
codesmell