This scenario comes up more times than one would think. In the long run, 
the choice comes down to an application designer's decision. The test I use 
is where or where not to overload a function and the effects on an 
application's structure. In my designs, I try to keep functions and 
structure as distinct as possible. This approach seems to make design, 
debug and maintenance easier.

<cfcase value="doSomething">
   <cfinclude template="actDoSomething.cfm">
   <cfinclude template="aQuery.cfm">
</cfcase>

In the above example, the structure is being overloaded rather than the 
method which means the structure becomes a program method. I think this can 
lead to some tangled code. If doSomething is a method, then the 
recommendation is to put the query functions in the method actDoSomething 
and not in the structure.

In some cases, extending the structure can be extremely beneficial. Like in 
the example below, the user's authentication is tested before allowing more 
access. This extension is more like a  door, which is part of a structure, 
but the office method, actDoSomething, does not change.

<cfcase value="doSomething">
   <cf_permisssion user="everyone" group="author,editor">
   <cfinclude template="actDoSomething.cfm">
  </cfcase>

To answer your question Hal, neither your first nor your second technique 
would not be a coding practice that I would use for the general solution.

Regards
Joseph


At 12:18 PM 4/9/2001, you wrote:
>Folks,
>
>Question on how you handle queries: Some people always include query files
>in other files, like this in actDoSomething.cfm:
>
><cfinclude template="/Queries/aQuery.cfm">
>
>Others let the fusebox itself handle this, like this:
>
><cfcase value="doSomething">
>   <cfinclude template="actDoSomething.cfm">
>   <cfinclude template="aQuery.cfm">
></cfcase>
>
>My question is this: if you use the second method, how do you handle the
>situation where you would only want to call "aQuery.cfm" IF a variable in
>"actDoSomething.cfm" was set to true? Do you do it in the fusebox, like
>this:
>
><cfcase value="doSomething">
>   <cfinclude template="actDoSomething.cfm">
>   <cfif includeQuery>
>     <cfinclude template="aQuery.cfm">
>   </cfif>
></cfcase>
>
>Or do you do something else? I'm just trying to see how different developers
>handle this situation.
>Hal Helms
>
>Team Allaire
>
>[ See www.halhelms.com for info on training classes ]
>
>
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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

Reply via email to