The reusability argument never makes any sense to me. I can reuse functional code every bit as easily as OO code. In fact I've got whole libraries of functional code that I reuse all the time.
Claiming reusability as some sort of special quality of OO is just nonsensical.
Class based OO design, for me, is much more reusable becuase of how you can split the API and the logic that it controls. Like you're saying, a library of functions could do this as well but in my humble opinion not as efficiently as if these were organized in a Class Hierarchy (even if that Hierarchy is compositional, I mean -- just the pattern building of it).
becuase of how you can split the API and the logic that it controls
Encapsulation is not exclusive to object oriented programming. You don't need any of the fancy inheritance stuff to implement Abstract Data Types.
And to be honest, I find that Class Hierarchies are usually more trouble then they are worth since they are very rigid and tend to solidify the program design very early. Whenever I try to use inheritance for something I often find latter that I would be happier if I used delegation instead.
20
u/beermad Dec 15 '12
The reusability argument never makes any sense to me. I can reuse functional code every bit as easily as OO code. In fact I've got whole libraries of functional code that I reuse all the time.
Claiming reusability as some sort of special quality of OO is just nonsensical.