On Nov 7, 2007 5:15 PM, Sam Larbi <[EMAIL PROTECTED]> wrote:
>
>
> >
> > 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()
> >
>
>
> Let the Law of Demeter be your guide:
> http://en.wikipedia.org/wiki/Law_of_Demeter
>
> It says you should go for option b, if I understand it correctly.
> However, I seem to have a slight preference for option A at times, and I
> can't recall when it has brought me trouble.
>
Thinking about this some more I've noticed a bit different trend than a
"slight preference for option A." I think I slightly prefer A when I'm
using someone else's code - some published API or framework where I can be
sure they are taking great pains to make a decision and stick with it. I
don't mind calling Model.Bones["bone_name"].Position.X when the framework
gives it to me that way, but I can't think of a time when I've written code
like that.
I'm sure it's happened, but nothing is standing out. In my own code, at
least lately, I think I normally try to follow Law of Demeter.
I'll certainly pay more attention for a while.
Sam
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---