On Sun, Nov 14, 2010 at 11:03 AM, Dave Merrill <enigm...@gmail.com> wrote: > In the cfproperty-oriented world, where properties get dumped into the > variables scope along with your methods and anything else there, many > folks including me have written getMemento methods to return a struct > with the values of the object's declared properties, only.
Why? If you wanted a struct, why use an object in the first place. If you wanted an object, why provide a method that un-encapsulates the data? > Do you suppose methods like this should use the values returned by > getters where they exist? Or just the raw internal data? Surely that depends on the object in question and what you'd expect client code to do with this mythical memento struct? > If you're populating another instance of the object from this result, Why wouldn't you pass the object itself into the constructor (of the new object) and let it get the data itself? If you see code like this, you have a code smell: a = obj1.getSomething(); b = obj1.getSomethingElse(); c = ... etc obj2.setSomething(a); obj2.setSomethingElse(b); ... // or obj2 = new SomeType(a,b,c...) In general, good OO code should not be calling getters and setters very much - you should tell an object to do something to its own data rather than pull the data out, do something to that data and then put that result into another object. If two objects need access to each other's properties, you may need a different design - but at least pass one object to the other rather than sucking the data out and passing that as multiple arguments to a call on the other method. -- Sean A Corfield -- (904) 302-SEAN Railo Technologies, Inc. -- http://getrailo.com/ An Architect's View -- http://corfield.org/ "If you're not annoying somebody, you're not really alive." -- Margaret Atwood ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:339301 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm