Now I think this is taking things a little too far. The main purpose of
FuseBox is to make things easier and quicker to
write/understand/maintain/debug/enhance.
Your first "if-boxed-in" solution looks just fine to me. I can see what's
going on, and more importantly, my juniors won't resign en-masse when asked
to work with it. Your solution "A", on the other hand...
Well, that's just my gut reaction. Perhaps I can justify it...
ColdFusion's CFLOCATION is the nearest thing we have to a GOTO. To be used
with caution. When the location of the GOTO's jump is itself a variable, as
in Solution "A", then we have an indirect jump, which takes me back to
writing my first sequencer in 6502-assembler. That's not a memory I want to
re-live ;-)
Go with the nicely structured conditional-inside-a-switch. It satisfies all
of the goals for which FuseBox was invented.
[In terms of software complexity, the boxed-in solution has a structured
complexity of 3 (program + case + if). Solution "A" has a structured
complexity of 4 (program + 3*case) PLUS an UNstructured complexity of 1
(goto).]
Many apologies for the lecturing. I know it was meant to just be a survey
;-)
Lee.
>From: "Patrick McElhaney" <[EMAIL PROTECTED]>
>
>If boxed into a corner, I would do this:
>
><cfcase value="doSomething">
> <cfinclude template="act_DoSomething.cfm">
> <cfif isConditionTrue>
> <cfinclude template="qry_aQuery.cfm">
> </cfif>
></cfcase>
>
>However, depending on the problem, I would
>usually approach the problem a completely
>different way.
>
>A)
>Break the fuseaction into two parts.
>
><cfcase value="doSomething">
> <cfset xfa.isTrue = "doQuery">
> <cfset xfa.isFalse = "skipQuery">
> <cfinclude template="act_DoSomething.cfm">
> <cflocation url="#self#?fuseaction=#xfa.condition#">
></cfcase>
><cfcase value="doQuery">
> <cfinclude template="qry_aQuery.cfm">
> ...
></cfcase>
><cfcase value="skipQuery">
> ...
></cfcase>
>
....
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists