Code Smell 37 - Protected Attributes
22 December, 2022
9
9
0
Contributors
Problems
•
Sub classification for code reuse purposes.
•
Liskov substitution violation (SOLID principle).
•
Possible subclass overrides.
Solutions
1.
2.
3.
4.
Wrong
Right
Detection
Tags
•
Conclusion
Relations
More Info
Credits
Subclasses shouldn’t always share all characteristics of their parent class but will do so with inheritance. This can make a program’s design less flexible. It also introduces the possibility of calling methods on subclasses that don’t make sense or that cause errors because the methods don’t apply to the subclass.