How to Apply the Open/Closed Principle Without Turning Every Feature Into a Plugin

TL;DR: The Open/Closed Principle (OCP) states: classes should be open for extension, but closed for modification. You don’t need to create a plugin for every new feature, favor simpler patterns like strategy, inheritance, or composition. Start with well-named abstractions; introduce extensibility points only when real change is expected. Keep code maintainable by balancing extension points with simplicity. Overengineering is a bigger risk than occasional refactoring. The Open/Closed Principle isn’t about making everything extensible. It simply means that your core business logic should be closed to modification but open to extension. The real skill is knowing when to apply it and when you’re just over-engineering your code. ...

July 11, 2025 · 10 min · 1871 words · Abhinaw