An example of how the tradeoff between Open closed principle and Indirection works out

Dear Reader,

In the Weekly Iteration video on the Open-Closed principle(OCP) around 11mins 30sec, Ben says “the benefits that we get from OCP are at the expense of indirection”. Can somebody please explain this with an example?

I’d like to better understand how the two are related and how we can benefit with only either of them at a given point in time.

Thank you.

When I said “indirection”, I was referring to the fact that following OCP means you will tend to create more classes in more files. If you want to understand a system like that, you have to jump around a bit.

Less indirection would be simply having lots of code in a single file.

Make sense?

Hi Ben,

This does makes sense and I now better understand how the two are related. Thank you.

1 Like