Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Re: Why get() and set() accessor methods are evil

by Ovid (Cardinal)
on Nov 25, 2003 at 15:46 UTC ( [id://310056]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re: Why get() and set() accessor methods are evil
in thread Why get() and set() accessor methods are evil

hardburn wrote: Two others are strings from user input. I suppose they could become objects, but I don't see a benifit to doing so.

While I don't think you meant to, you actually touched on a fundamental point in favor of OO programming: create an object when you have invariants that must be respected.

If the user can enter any arbitrary string, then there's not much point in using an object. However, if the string must be validated in some way (such as with a URI), then creating an object is perfect. At the very least, I suspect that your strings might have a length limit. If that is the only invariant that you need to worry about, perhaps it's not worth the overhead of creating an object (particularly since you'll likely be validating length via your Class::DBI objects). If you have any more invariants, then using an objects can be a great way to ensure that the data is what you intended it to be.

Cheers,
Ovid

New address of my CGI Course.

  • Comment on Re: Re: Why get() and set() accessor methods are evil

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://310056]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.