NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
That's not what I call 'inside-out' objects. (Score:1)
People seem to think that Inside-Out Objects are about not letting other people touch your internals.
They aren't.
Inside-Out Objects solve two out of three problems* I have with traditional Perl OO:
The first point means that OO programming isn't much better than programming in perl4 (not only don't you have the benefits of compile time errors, you don't have name spaces either).
The second point means that Perl is making easy things hard: code reuse is much harder that it should be.
The point of IOO isn't so much that it prevents other classes from accessing the internals (if you want to, changing a few 'my's to 'our's gives access, without giving up any of the other benefits of IOO), it's about giving classes the freedom to do whatever they want, without accidently touching someone elses internals.
The implementation you suggest doesn't solve any of the problems IOO solves. You don't get compile time errors on mistyping attribute names, and you will put a dependency in the inheritance tree.
Now, I won't judge your implementation as good or bad - if it works for you then it should be good enough, if it works for others so much the better. Just don't call it a different way of doing Inside-Out Objects. They aren't.
*: The third point being: too much typing to get to an attribute.
Reply to This
Re: (Score:2)
I've evidently been wrong about IOO. Since the major problem I've faced has traditionally been encapsulation, that was the bit I've focused on. I will have to concede all your points. I just find that virtually every IOO implementation I've seen out there has been painful to work with, so I gave up and hope that solving the major problem I have might be good enough.
Re: (Score:1)
Hmm. For me, the visible difference between hash-based and inside-out objects is turning the following:
into this:
That seems hardly painful… but then, as MJD says, people are weird about syntax.