in reply to •Re: Make Perl an OO language
in thread Make Perl an OO language
I wouldn't say inheritance is the end-all criterion to decide whether to use OO, nor even is data hiding. I relatively often find myself using OO even when I need neither.
I often have a bunch of functions that all deal with a specific, non-trivial data structure and only make sense in the context of this data structure. In this case I usually bundle them into a class and then use the OO syntax on the resulting objects so as to have that data structure implicitly passed around. I am not doing real OO there of course, but the syntactic sugar makes the code easier to read - sometimes dramatically so.
See rules 2, 6, and 10 of Damian Conway's ten rules for when to use OO.
Makeshifts last the longest.
|
---|