Unless there is some great need to use a single line of code to perform multiple actions, don't do it.
It's only worth doing if it is actually clearer.
<cfset obj.setFirstName("Sean") /> <cfset obj.setLastName("Corfield") />
is hardly any extra typing, and it's clear that what's happening is two separate actions.
Perhaps, but this sends a different 'message' to the reader:
obj.setFirstName("Sean").setLastName("Corfield");
It says setting both the first and last names is (sort of) an atomic action, rather than two separate actions.
Similarly, having init() return this allows the following:
x = createObject("component","mycfc").init();
which again makes the create + initialize into a visually 'atomic' action.
Sometimes that is clearer.
Here's my favorite example of a single line that does everything
And that is indeed a good example of how not to write code. But just because you have an extreme example does not mean that it is *always* wrong to merge two lines into one...
Sean A Corfield -- http://www.corfield.org/blog/
"If you're not annoying somebody, you're not really alive." -- Margaret Atwood
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com).
