Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Re^3: "Rites of Passage" wheel reinventing

by grantm (Parson)
on Feb 27, 2004 at 18:50 UTC ( [id://332327]=note: print w/replies, xml ) Need Help??


in reply to Re^3: "Rites of Passage" wheel reinventing
in thread "Rites of Passage" wheel reinventing

One big advantage of accessors over passing round a hash is that if you mis-type an accessor name you get an error about an unknown method whereas if you mis-type a hash key you get a bug that may be hard to diagnose.

  • Comment on Re: Re^3: "Rites of Passage" wheel reinventing

Replies are listed 'Best First'.
Re^5: "Rites of Passage" wheel reinventing
by hardburn (Abbot) on Feb 27, 2004 at 19:17 UTC

    That's an advantage in Perl5, yes, but good class design is language-agnostic. There might be a language which provides locked keys for hashes by default, or perhaps you use one of the locked keys implementations in Perl (using a tied interface). Or maybe your language doesn't have hashes, but it has structs which are statically typed and serve the same purpose, and thus a compile-time error is generated anyway.

    ----
    : () { :|:& };:

    Note: All code is untested, unless otherwise stated

      Perl5 has pseudo-hashes too, and those offer fixed keys.

        Pseudo-hashes are deprecated anyway.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-04-19 21:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found