What are the architectural implications of using 'Final' classes by default in a large-scale application?
Last updated
Making classes
final(non-extendable) by default enforces composition over inheritance. It prevents fragile-base-class coupling and lets you refactor internals freely.The cost: some mocking tools need to extend classes, so mock interfaces instead. Extension points must also be designed deliberately (interfaces, hooks, decorators).
Practical rule: make concrete classes
final, program against interfaces, and open a class only when subclassing is part of its contract.
- https://gist.github.com/sj-i/7981487f879bd9aad8f57a931de1591e?permalink_comment_id=4233557
- https://exakat.readthedocs.io/en/stable/Rules.html
- https://github.com/piotrplenik/clean-code-php/blob/master/README.md
- https://www.geeksforgeeks.org/websites-apps/hospital-management-system-project-in-software-development/