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.