Products

Products
Viewing By Entry / Main
June 20, 2009

Consume object or object property

Here it is in a nutshell. I have a controller cfc in my framework that directs execution instructions to the business model cfc's. But I'm wandering if I should pass whole objects, like a user object, and get values as needed from it's methods within the business model? Or should I just pass the object's properties to the business model classes as needed?

Another way to put it is this(model/securityService.cfc):

instance.securityGateway.login(User.getUsername(),User.getUserpassword());

or

instance.securityGateway.login(User);

The business model gateway in this example would be something like(model/data/gateway/securityGateway.cfc):

<cffunction name="login"..>
<cfargument name="username"../>
<cfargument name="password"../>
...
</cffunction>

or

<cffunction name="login"..>
<cfargument name="User" type="model.data.gateway.User"../>
..
</cffunction>

Maybe because I'm not a seasoned OO veteran but I'm looking at this and trying to figure out the best course and can't decide which one to take. From the service cfc do I pass in the user object or it's properties (username & password)?

For now I'm passing the object's properties if the gateway method only requires data and doesn't need to access any of the objects other methods like setters. If the gateway method here needed to use the object's methods instead of just it's properties, then I'd pass the entire object. So what do you think is best practice?

Comments

<b><a href="http://www.1stceramics.com">Ceramic Mug</a></b>
<b><a href="http://www.1stceramics.com">CUP Mug</a></b>
<b><a href="http://www.1stceramics.com">bone china</a></b>
<b><a href="http://www.1stceramics.com">Ceramic plate</a></b>
<b><a href="http://www.1stceramics.com">Stock Ceramic Mug</a></b>



Copyright © 2005-2006 Clint Willard. All rights reserved.
Aura skin for Clint Willard's BlogCFC inspired by Brooks Bilson's Bolg.
All trademarks property of their owners.