Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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

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


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
Node Status?
node history
Node Type: note [id://310056]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2021-01-17 22:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?