Know why you don't like OOP
18 hours ago
- #Performance Optimization
- #Programming Best Practices
- #OOP
- Programmers debate OOP; junior anti-OOP developers often echo others without firsthand experience.
- Approach code in a way that makes sense to you, but avoid known pitfalls.
- Interfaces are useful for supporting multiple APIs or allocators, and don’t require OOP language features.
- Methods are fine as a code organization tool if the language supports them.
- Encapsulation can be good for stable APIs but often annoying when overused; default to public access.
- Inheritance is often bad for performance due to scattered memory allocations, harming CPU cache efficiency.
- Modeling after the real world is a rare corner case and not a valid criticism of most OOP codebases.
- Use interfaces and methods if desired, avoid inheritance for performance-critical data, and form opinions based on experience.