[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

RE: [FWP] do... while? SPOILER



>I'm not sure I see why you need the objects at all.  That is, couldn't you
>do your example as a normal hash.  The "added" maintenance would be that the
>"constructor" (where you initialize the hash) would need the names of the
>values, in addition to the actual values.  But the savings in maintenance
>would be, as you point out, the lack of all these classes floating around.
>So, if as you say, the class is just a bunch of accessor methods, just do:
>
>my %Object1 = (a1 => $a1, a2 => $a2);
>
>Then the accessor "Object1->geta1" becomes "$Object1{a1}", etc.

One reason is the usual formula: separating implementation from
interface. We might want to implement these objects as array refs
or packed strings or whatever. The programs using them shouldn't
change.

However, *I* have no qualms at all about having hash lookup as the
interface; and with tie() etc, the conceptual difference in my mind
dwindles to nothing. So a hash lookup is as good an accessor as any.
Does this make me a revolutionary and heretic? No, probably just too
perlish and clueless...

--
Tushar Samant
~
~
:wq


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe