Tag: OCP

Latest Posts
Open/Closed Principle: Add, Don’t Rewrite

InPost just changed their pricing model. Again. You open ShippingCalculator, find the switch statement, locate the InPost branch, and carefully edit the formula. While you’re in there, you notice the DHL branch looks suspicious too. You touch it. Now two things are broken instead of one.
This is the cost of code that is never finished being modified. The Open/Closed Principle offers a different approach: write code that you add to, not code that you keep rewriting.