http://qs321.pair.com?node_id=561619


in reply to class inheritance and new(constructor)

I use, and recomend, Class::Std and Class::Std::Utils, or Moose than a pseudohashes OO based to implement best practices and more (and best) control over access of variables and values, constructors and destructors of my class.

Theses modules implement, and recomend you to use specials methods (BUILD and DEMOLISH) to be a constructors and destructors of your class. Theses build-in methods will manager all the class hierarchies and inheritance works.

If you don't know theses modules, I strong recomend you to take a look of them.

Solli Moreira Honorio
Sao Paulo - Brazil

Replies are listed 'Best First'.
Re^2: class inheritance and new(constructor)
by doom (Deacon) on Jul 17, 2006 at 07:28 UTC
    Class::Std and friends are of course the modules written by Damien Conway and endorsed in his "Perl Best Practices" book. These are one way of doing "inside-out objects", which have the advantage of encapsulated internal state (with hash based objects you can access a field of the hash directly if you feel like cheating, with inside-out objects you're forced to use the accessors).

    I haven't played with this concept much myself: they sound neat, but I think they're still a little too new. For example, there's some debate about whether "Class::Std" is really the right way to do it. I quote from the documentation for Class::InsideOut:

    * Class::Std -- Despite the name, this does not reflect currently known best practices for inside-out objects. Does not provide thread-safety with CLONE and doesn't support foreign inheritance. Has a robust inheritance/initialization system.