©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. [email protected] 301-881-1440 x110...

39
©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. [email protected] http://www.teratech.com 301-881-1440 x110 Copyright TeraTech 2003

Transcript of ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. [email protected] 301-881-1440 x110...

Page 1: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

Fusebox 4

Michael Smith, TeraTech, [email protected]

http://www.teratech.com

301-881-1440 x110

Copyright TeraTech 2003

Page 2: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

Overview

What is Fusebox What is Fusebox 4? How Fusebox works Circuit syntax Fuseactions Layouts and Content variables Extending Fusebox 4 with plugins

Page 3: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

Speaker Information

Who am I? Michael Smith President of TeraTech, Inc Rockville MD

> http://www.teratech.com/> ttWebReportServer, CFXGraphicserver

MDCFUG, CFUN-03, Fusebox Conf Articles in CFDJ, Fusion Authority Winner CFDJ award Best CF Consulting

Page 4: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

More About Me

22 years programming 7 years with ColdFusion 4 years with Fusebox Also work with SQL, JavaScript, HTML, VB,

Oracle, Access Teach one-on-one and custom classes On site and custom development Fusebox and Process Methodology

Page 5: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

What is Fusebox?

Way to organize code and files A methodology for programming A core file that supports the above A non-profit organization (fusebox.org) that

coordinates the above

Page 6: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

Benefits of Standardization

Better team communication Cheaper maintenance Can pick up others code faster Fewer bugs due to different styles Can think about the fun stuff instead of code

structure

Page 7: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

Why Fusebox?

Fusebox began and continues to be guided by a developer community concerned with making their projects more successful, their clients happier, and their own work less frustrating and more rewarding.

Page 8: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

What makes Fusebox 3

Routes via index.cfm?fuseaction=c.fa Separate HTML, SQL, CF in fuses Central switch for control Nested Circuits Nested Layouts Compound Fuseactions Exit Fuseactions (XFA’s) XML Fusedocs

Page 9: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

Fusebox Project Life Cycle

Wireframe HTML Prototype Prototype + Devnotes Final Code + Devnotes Sign off

Page 10: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

Fusebox 3 Core Concepts

Fusebox 3 core concepts> all actions of the software occur as a response to

a request made of the fusebox> code is encapsulated in circuits> circuits are made to be as independent of each oth

er as possible (new requests return to the fusebox rather than being routed directly to another circuit)

> fuses are based on "pipes and filters" where the output of one file becomes the input of the other, allowing for ease of reuse

Page 11: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

New capabilities in Fusebox 4

Fusebox 4 makes development even easier> XML configuration files provide language independence> multiple fuseactions in a single HTTP request allows for

more flexible design patterns such as MVC> pre-parsing of files means better performance> layout files lose their minority status—simply another fuse> the <cfflush> tag can now be used> plugins let developers modify functionality without editing

the core files> content component variables allow developer to break page

into multiple component blocks

Page 12: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

What about CFCs?

Nothing in Fusebox 4 prohibits the use of CFCs, but they are not required

Fusebox MX addresses the issue of object oriented programmingwith CFCs

Page 13: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

Fusebox terminology : fuseaction

A fuseaction is the request made of a Fusebox application

> <form action="index.cfm?fuseaction=Login.validate">> <form action="index.cfm?fuseaction=Survey.store">> <form action="index.cfm?fuseaction=Users.update">

Page 14: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

Compound Fuseactions

A request made of the server to perform some action is known as a fuseaction.

Fuseactions are made up of the circuit name, a dot separator, and the actual request.> Cart.addItem> Users.login> Scheduler.requestMeeting> Noun.verb

Page 15: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

Fusebox terminology : circuit

A circuit is a logical grouping of related fuseactions

> www.teratech.com/index.cfm?fuseaction=Training.details> www.teratech.com/index.cfm?fuseaction=Training.register> www.teratech.com/index.cfm?fuseaction=Training.confirm

Page 16: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

Fusebox terminology : fuse

A fuse is an individual code file used either singly or in combination with other fuses to carry out a fuseaction

<cfcase value="listUsers">

<cfinclude template="qry_AllUsers.cfm" />

<cfinclude template="dsp_UsersList.cfm" />

</cfcase>

<fuseaction name="listUsers">

<include template="qry_AllUsers.cfm" />

<include template="dsp_UsersList.cfm" />

</fuseaction>

FB4

FB3

Page 17: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

The Fuse Rules

Length Challenged Reuseable Standard Prefix: qry_, dsp_, act_ Prefix Rebels HTML, SQL or CF only Contains Fusedocs Clueless – blackbox – no includes Check inputs Good Name – no abv Name recordset after fuse name

qry_FuseName

Page 18: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

Fusebox processing

Index.cfm calls FB core file with circuit and fuseaction from URL or Form variables.

FB core parses circuit names from fusebox.xml.cfm FB core parses correct circuit.xml.cfm and fuseaction

from circuit.xml.cfm> Select fuses or fuseactions to execute from circuit.xml> Repeat for rest of Fuse Queue> Save to compiled CFM> Run the CFM

At certain point in core processing plugins may be added

Page 19: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

A sample page viewed by a user…

Page 20: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

…is seen as a collection of requests made of the Fusebox application…

Company.getCurrentStockPrice

Employment.newestJobs

Training.upcomingEvents

Benefits.notes

Page 21: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

Fusebox 4 demonstration

The code used in this demonstration is available at beta.fusebox.org

Page 22: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

New features

Plugins let you change how FB core behaves Better for MVC – run fuse built in Compiled – faster FBX config files now in XML format

Page 23: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

Fusebox.xml.cfm

This XML file configures your Fusebox application

Circuit definitions and locations and parents Global fuseactions Plugin phases In app root directory Replaces fbx_circuits.cfm Uses .cfm file extension to prevent hackers

from browsing and to allow editing in CF Studio (VTML helpers available)

Page 24: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

Defining Circuits

FB3<cfset fusebox.circuits.home = "/home"><cfset fusebox.circuits.Users = "/home/Users">

FB4<circuits>  <circuit alias="home" path="" parent=""/>  <circuit alias="Users" path="Users/" parent="home"/></circuits>

Page 25: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

Fusebox Parameters

<fusebox-parameters>

<parameter name="fuseactionVariable" value="method" />

<parameter name="defaultFuseaction" value="Controller.dspHome"/>

<parameter name="precedenceFormOrUrl" value="form"/>

<parameter name="execute" value="true"/>

<parameter name="parseWithComments" value="true"/>

Page 26: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

More parameters

<parameter name="mode" value="development"/>

<parameter name="scriptlanguage" value="cfmx"/>

<parameter name="scriptFileDelimiter" value="cfm"/>

<parameter name="maskedFileDelimiters" value="htm,cfm,cfml,php,php4,asp,aspx"/>

</fusebox-parameters>

Page 27: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

Global fuseactions

Can run fuseactions at the beginning or end of every page request

<globalfuseactions> <preprocess> <postprocess> Used for header and footers

Page 28: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

Plugins

Let you change what happens in the core without having to edit its code> preProcess: called once, at the beginning of the request

processing > preFuseaction: called once per fuseaction, prior to the

invocation of any fuseaction > postFuseaction: called once per fuseaction, after the

invocation of any fuseaction > fuseactionException: called once per fuseaction, if any

exception was thrown during that fuseaction> postProcess: called once, at the end of the request

processing> processError: called once, if any error was thrown during the

request processing

Page 29: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

Circuit.xml.cfm

Replaces fbx_switch.cfm and fbx_layout.cfm Contains fuseactions and fuses to call May also contain logic Content Variables Uses XML FB language format similar to

CFML without the CF on the front of each tag Parsed by FB4 compiler into CFML.

Page 30: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

Circuit syntax

Including a fuse:<fuseaction name="Login">  <include template="dspLogin.cfm"/></fuseaction>

Calling another fuseaction:<fuseaction name="listProducts">  <do action="m.getProducts"/>  <do action="v.displayProducts"/></fuseaction>

Page 31: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

In FB 3 that would have been:

Including a fuse:<cfcase value="Login">  <cfinclude template="dspLogin.cfm"/></cfcase>

Calling another fuseaction:<cfcase value="listProducts">  <cfmodule template="index.cfm" fuseaction="m.getProducts">  <cfmodule template="index.cfm" fuseaction="v.displayProducts"></cfcase>

Page 32: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

XFAs

Exit FuseActions are variables to avoid hardcoding exit points in your code

<cfset xfa.submitForm = "c.dspConfirm"> In the circuit.xml.cfm you can use

<set name="xfa.submitForm" value="c.dspConfirm"/>

Page 33: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

Content Component Variables

Create by “do action”ing a fuseaction<do action="View.dspHome"

contentvariable="WelcomeCCV"/> Result is streamed into the variable for later

output Uses CFSAVECONTENT tag Output variables in layout file – good for

portal applications. Note: fusebox.layout variable is no longer

automatically created

Page 34: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

Layout Example

Layouts are no longer special cases, but just regular fuses.

<fuseaction name="dspHelloWorld">  <do action="v.HelloWorld" contentvariable="myContent"/>  <do action="Layout.simpleLayout"/></fuseaction>

Page 35: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

Final thoughts

Why use Fusebox?> easier to develop applications> easier to maintain existing code> aids in code repurposing> standard for web application development> supports teams of diverse talents and skills> provides a standardized documentation> exceptionally helpful community of developers> cross-language> helps ordinary developers achieve extraordinary

results

Page 36: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

Why not?

Why not use Fusebox?> you're being paid by your competitor to sabotage

your company'sdevelopment efforts

> framework? you don't need no stinkin' framework> you have a strong masochistic streak that enjoys

the pain of your current software development process

> you made a decision against Fusebox early on and haven't bothered to reevaluate it

> call you crazy, but you just like to code by the seat of your pants!

Page 37: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

How about a Fusebox book?

Discovering Fusebox 4 by John Quarto-vonTivadar with Sandra Clark, Brian Leroux and Perry Woodin

Consise coverage of Fusebox 4 framework

www.techspedition.com Out by September

4

Page 38: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

How to get Fusebox 4

Currently FB 4 in beta Free download from beta.fusebox.org Requires ColdFusion MX CF 5 version in the works (uses XML parsing

add on).

Page 39: ©2003 TeraTech, Inc Fusebox 4 Michael Smith, TeraTech, Inc. michael@teratech.com  301-881-1440 x110 Copyright TeraTech 2003.

©2003 TeraTech, Inc

Questions

[email protected]