I like for each line to have a bit of *meaning* rather than just disparate
commands for readability. So I am a fan of metered chaining:
<!--- read user --->
<cfset User.setID(123).Read() />
<!--- save new values --->
<cfset User.setName('NewName').setPassword('NewPassword').Save() />
Baz
On Sun, Jan 4, 2009 at 1:13 PM, Sean Corfield <[email protected]>wrote:
>
> On Sun, Jan 4, 2009 at 1:50 AM, Alan Livie <[email protected]> wrote:
> > Is this for readability reasons or something else I'm not aware of?
> >
> > I think setter methods (and maybe other methods that return VOID)
> > returning THIS is a sensible idea so we can chain or not chain as we
> > see fit.
>
> I go back and forth on this. In Edmund (my event-driven model
> framework), I use method chaining a lot and there are few void returns
> (but there are few setters). It's all about whether the resulting code
> is easier to read with chaining vs intermediate result variables.
>
> For example:
>
> edmund.new("model.events.MyEvent").values(a=1,b=2).dispatch();
>
> vs:
>
> e = edmund.new("model.events.MyEvents");
> e.value("a",1);
> e.value("b",2);
> edmund.dispatchEvent(e);
> --
> Sean A Corfield -- (904) 302-SEAN
> An Architect's View -- http://corfield.org/
>
> "If you're not annoying somebody, you're not really alive."
> -- Margaret Atwood
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---