Sunday, September 18, 2005

When to apply OO in programming

I have been thinking some more on Object oriented programming. In school we read "Object-Oriented Modelling and Design" by Rumbaugh et.al.. The book and the teacher made a big issue out of mapping real-world objects to programming-objects and that inheritance promotes code reuse. I was quite enthusiastic about the book at the time, but now don't think this book did me much service.

Now I think that OO shouldn't be applied forcefully in the design phase (one-off design), and I don't think code-reuse is a big issue. I am convinced that inheritance relationships often do not become apparent until the code is refactored. I also think that one should not force a inheritance relationship onto classes except where needed, i.e., at the hinge-points (as Robert Martin calls them). Inheritance should be introduced while refactoring in order to simplify the code, manage its complexity, as I think Steve McConnell would put it.

No comments: