good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Inside Out Classes and the internal Hashesby KurtSchwind (Chaplain) |
on Dec 17, 2007 at 20:53 UTC ( [id://657514]=perlquestion: print w/replies, xml ) | Need Help?? |
KurtSchwind has asked for the wisdom of the Perl Monks concerning the following question: I've been working on some OO perl and I'm just starting to work with Inside out classes. Every example I see is very similar and I can emulate it without a problem. However, I've taken a different approach and I can't find an example that does it the way I plan on doing it. So am I just way off here? Is there a major flaw in my method? Here seems to be the traditional inside-out class :
But am I wrong if I get rid of the multiple hashes and go with a single hash ref like this?
In the second example, I wrote a test program that seems to work just fine and as I'd expect. which produces the output:
So why do most things just keep adding internal hashes instead of using 1 hash for everything? I'm new to this inside out class way of doing things, so I want to nip any bad habits in the bud (if indeed this is a bad habit). This is a trivial example of just having 2 items tracked with a single hash. My current application will track around a dozen. I'd prefer not to have a dozen hashes, but I will if it's deemed to be The-Right-Thing (tm).
-- I used to drive a Heisenbergmobile, but every time I looked at the speedometer, I got lost.
Back to
Seekers of Perl Wisdom
|
|