http://www.perlmonks.org?node_id=646254


in reply to The world is not object oriented

There is OO as a method of encapsulating and associating data and the means to operate on that data, and there is OO as a method of modeling an abstract concept. Both have their place, however I tend to find the latter is actually less useful than the former. The former tends to use 'hasa' or 'containsa' semantics and the latter tends to use 'isa'.

I find programming in an environment that requires isa semantics to be frustrating and annoying (outside of perhaps mix-ins). I tend to find that inheritance and polymorphism to be overused and less useful than is typically advertised, leading to layers of twisty two line subroutines that obscure the actual intent and operation of the code.

On the other hand I find OO as an encapsulation mechansim to be of clear utility, especially in Perl where there are no type declarations. If I build a data structure out of AoAoHoA's and i accidentally feed it to a routine that doesn't operate on that structure the error is neither caught at compile time nor is the error message all that useful, and in fact given autovivification sometimes no error at all occurs, merely incorrect and surprising results. With OO as encapsulation this does problem does not arise, while the error message still will not occur at compile time, an error *will* arise when I call a method on an object that it does not define. Such an error is easy to debug, and is generally preferable to silent erroneous operation.

I think OO is like anything else, used with moderation its fine, used as an end-all-be-all matter of policy is ridiculous.

---
$world=~s/war/peace/g