in reply to Re: Re: Re: Re: Re: Reducing Perl OO boilerplate
in thread Reducing Perl OO boilerplate
Mammoth constructors have absolutely nothing to do with inheritance. Inheritance is, for all practical purposes, determined when using the two-part form of bless. Nothing more, nothing less. Here's an example:
No offense, but when I mix concepts, I *mean* to mix concepts :) I don't need the CS 1 / CS 2 intro to OO class. I could teach the class (just not in Perl). Perl's OO syntax isn't pure as it should be (yet), so it takes some effort to figure out the idioms -- which has never been the case in any other language supporting OO that I've picked up.
But yes, the init hook suggested in the above replies (especially Class::Method_Maker) is what I want. Java and C++ can make use of super constructors, the init hook is exactly what I was asking about, as my named parameter implementation as the OP (sans init hook), had a few glitches that would not provide the things init() provides.
Essentially my requirements were three-fold: (A) keep the code clean (solved: MethodMaker), (B) No long mamoth constructors, so named params help (solved: hash), (C) need instructors to benefit from inheritance (solved: init hook). Success. However arriving at this was an experience!
|
|---|