Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

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.


New address of my CGI Course.

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

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2022-05-24 21:50 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (84 votes). Check out past polls.