I have a bean called User that is composed of an Address bean. At the
moment its a 1:1 relationship.

A factory handles the composition so when I request User I get it
configured with the Address bean already composed.

My question is in 2 parts:

1) When I want to get and set properties of the Address bean from
client code should I
a) use objUser.getAddress().setCity("Dundee") or
b) should I have setters in the User object that delegates to the
Address object ie objUser.setCity("Dundee") and in User.cfc have the
method setCity() doing variables.objAddress.setCity()

2) If I want to save the address using a DAO how should I approach it?
At the moment I have a UserService cfc that calls the save() method in
the UserDAO. I don't like the idea of UserDAO having to use the
AddressDAO to save the address as it seems I'm giving it a
responsibility it shouldn't have. I thought about the service layer
and would run UserDAO.save() then call
AddressDAO.save(objUser.getAddress()). This also seems wrong as I feel
I'm losing the benefits of the composition in the first place by
calling 2 save() methods in 2 DAO's for the composed bean. Should
UserDAO itself be composed of an AddressDAO so it is set up in the
same way as the Beans?

I hope this makes sense! :-)


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CFCDev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cfcdev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to