Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: class inheritance and new(constructor)

by shonorio (Hermit)
on Jul 16, 2006 at 23:45 UTC ( #561619=note: print w/replies, xml ) Need Help??


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
  • Comment on Re: class inheritance and new(constructor)

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://561619]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2020-11-27 12:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?