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

Re^2: Using the strict module in object oriented programming

by Codon (Friar)
on Jul 25, 2006 at 17:18 UTC ( #563588=note: print w/replies, xml ) Need Help??

in reply to Re: Using the strict module in object oriented programming
in thread Using the strict module in object oriented programming

I would highly recommend using Inside Out objects. They keep others from dipping into the internals of your objects and thereby tying your hands through their poor practices.

Inside Out object do have limitations of sometimes being inconvenient for you as a user, but you as the maintainer can minimize those inconveniences by providing methods to dump the object, etc.

Perhaps more importantly for large systems, though, is the fact that method accessors can impose a performance hit by requiring the method call (as opposed to the hash look-up). So make sure that your accessors are well optimized in these situations.

If you have massive amounts of code that treat your objects as hashes and you don't want to refactor all of that code, you could look at refactoring your object to actually have a hash-based interface, but do method calls internallys. Lookups to non-existant "hash keys" could throw an exception. Take a look at the internals Regexp::Common (if you can follow it). It basically provides a nested hash interface, but each level of nesting acts both as a string (returns a pattern) and as a hash ref for deeper nesting. Rather cool. This could let you provide a strict "hash-like" interface to your objects.

Ivan Heffner
Sr. Software Engineer, DAS Lead, Inc.
  • Comment on Re^2: Using the strict module in object oriented programming

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://563588]
Discipulus thanks back and passes around a weis bier in the berghastof hummelei celebrative glass

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2018-05-25 17:01 GMT
Find Nodes?
    Voting Booth?