20.2 Problems and Criticisms of OOP
Despite its success, OOP has faced several criticisms:
- Rigid Class Hierarchies: Inheritance can make codebases brittle; changes in a base class may unexpectedly break derived classes.
- Excessive Class Usage: Everything becomes a class, even when simpler data structures and functions might suffice.
- Runtime Penalties: Virtual function calls (in languages like C++ and Java) incur a runtime cost because the exact function to be called must be determined dynamically.
- Over-Encapsulation: Hiding details can sometimes make systems harder to debug, especially if important information is obscured behind private fields and methods.
Languages such as Rust respond to these concerns by emphasizing composition (building features from smaller, cooperating parts) and fine-grained control over how data and functions are exposed.