Skip to Content

image

As you know I’ve been an active web developer for a long time now. In my time I’ve seen a lot of web development technologies come and go. All these technologies promised (and still do) a lot of goodies and technological innovations, but they usually forgot one thing: development methods. No-one seems to worry about this at all. Whereas classical development has had development methods for ages, web development has been left in the cold for a long time. Even when internet technology was booming developers coded their complex web applications. Even with outsourcing, offshoring, etc. no-one seems to bothered very much. At my previous place of work we had some massive projects that were developed with the assistance of an ODC (Overseas Development Centre) in Bangalore , India . Before we started any coding (this is already more than 5 years ago) we needed to define a method that ensured us:

  • A common ground of understanding, not only for the requirements of the project, but also for the coding of it. It was a “must” that each developer (wherever he/she was stationed) should be able to understand each other’s code and was able to modify or add code to it.
  • Integration of code had to be seamless, whatever the size of the whole was. Since delivery time was always short (yesterday was always better than today), we couldn’t waste time on figuring out how one code could understand the other code.
  • Testing and debugging of the whole could be done efficiently
  • Updating code in future phases would be swift.

So we started looking for a development method, or better said a framework, that could fulfil our requirements. Of course it should be something with web development, preferably something for Coldfusion, since that was the platform we were working on. We found it in something called “Fusebox”. This method (it’s not a tool) matched our needs exactly.

 

Everything’s in a name?

The name of this framework is rather appropriate. Let’s look at a house, which is (hopefully) equipped with electricity. The wiring of it is done in a specific way. The grid is centralized via a main fuse box from which several circuits start. It would be something if each device had their own direct line to the public network. If a circuit failed because somebody switched on the washing machine, tumble drier and vacuum cleaner all at the same time, and the fuse blew, the rest of the house wouldn’t be left without electricity.
You probably find all of this pretty obvious, so why don’t we extend this to web development? And that’s where the framework called Fusebox starts. Generally speaking, a web application has one single entry point in Fusebox. This single entry point directs the programming flow just like in a household fuse box. Wait a second, doesn’t this smell bit like a class and it’s methods in OO? Indeed, when Steve Nelson and Gabe Roffman devised Fusebox back in 1997, they used OO ideas to create this framework. It was intended for use with procedural languages like PHP and Coldfusion, but more on that later.

 

The basics

The framework’s aim is to separate logic from presentation layers. Doesn’t this sound familiar? Yes, it’s an MVC model avant la lettre. But it does more than that. Database interaction, functionality, display, and coding are kept separately in as modular a form as possible. Such a modular identity is called a fuse. It contains the code for a single action. But one swallow doesn’t make a summer, nor does one fuse. A fuse is a building block of a higher level task, called a fuse action. This fuse action will call all necessary fuses to complete a task. Typical examples of a simple fuse action are viewCart, viewCatalog, addItem, checkOut. All related fuse actions need to be grouped in a self containing logic. As in a household electricity circuit they work independently and will not influence other circuits. An example of such a circuit is the booking of a flight, which fits into a larger whole of an airline site.

 

What does it look like?

As mentioned earlier, Fusebox is suitable for several languages. The language that it was originally conceived for was Coldfusion. It’s now also available for PHP, ASP .NET (in development), Lasso and J2EE JSP. Why this distinction between the languages? Well, it’s because a Fusebox application needs some core files in order to let it work. These core files do the dirty work for you. For the sake of simplicity I will explain the mechanism for PHP for Fusebox version 3. Why PHP? I reckon that SDNers wouldn’t have much interest in Coldfusion (yet), although it’s a very nice and powerful language. I mention FB 3 since, from an educational point of view, it’s the best choice.

As said, Fusebox is built upon certain core files:

  • fbx_Circuits.php is used by the Fusebox application to keep track of where it is in the folder structure of the application. There is only one fbx_Circuits file in an application. A file could look like
    $Fusebox["circuits"]["Home”] = "myApp"; $Fusebox["circuits"]["Admin”] = "myApp/Administration";
  • fbx_Settings.php is used to set default values. There must be one settings file in the root folder of the application, but individual circuits can have their own settings if default values need to be set only for the files in that circuit, or default values of a higher circuit.
  • fbx_Switch.php is in fact the controlling mechanism of an FB application. It is best explained with an example:
    switch($Fusebox["fuseaction"]) {
    case “showFlights”:
    include(“qryFlight.php”);
    include(“dspFlightsTable.php”);
    break;
    case “selectFlight”:
    include(“actSelectFlight.php”);
    break;
    default:
    echo “Pls use a valid fuseaction“;
    break;
    }
  • fbx_Layouts.php is used for the look of each circuit. There must be at least one fbx_Layouts file in an application. Any circuit that has its own layout requirements should have its own fbx_Layouts file. Such a file could look like
    if($Fusebox["isSDNCircuit"]) {
    $Fusebox["layoutFile"] = "sdnLayout.php";
    } else {
    $Fusebox["layoutFile"] = "typicalLayout.php";
    }
  • fbx_FuseboxXX_PHPYY.php. The XX needs to be replaced by the FB version and the YY with the PHP where it’s written in. A filename could look like fbx_Fusebox3.0_PHP4.0.6.php. From a Fusebox perspective, this is the most important core file. The main tasks of this files are:
    • to set a number of variables and to initialize structures.
    • to include the fbx_Circuits.php file for (reverse) lookup of the circuits.
    • to include the fbx_Settings.php file
    • to get the Fuseaction and the circuit that was sent to the application.
    • to includes the fbx_Settings.php files from all the subfolders in top to bottom order.
    • to execute the Fuseaction in the correct circuit’s fbx_Switch file.
    • to include the fbx_Layouts.php files from all the subfolders in bottom to top order.

 

Besides the core files, there are of course the application files. These is no need to follow a strict naming convention but the following prefix abbreviations must be used:

  • dsp_ : display files
  • act_: action files, meaning all code without layout or database interaction
  • qry_: query files, meaning all database interaction
  • inc_: include files make the code scalable and reusable

 

Up and running

What else do I need to make a FB application? Nothing at all. The most important thing is that you understand the philosophy. This web log is only a teaser though and is not intended to make you a FB expert. There is plenty of good material (documentation, web logs, books, forums, …) available at fusebox.org to discover. The best way to learn is to explore the example applications (with core files) for PHP and JSP . You will notice that the specifications of version 4 are out now. Fusebox is a continuously evolving methodology which tries to comply with the demands of the web developers in their search of a good methodology for structuring their complex applications.

Btw I mentioned earlier that FB was rather procedurally oriented. If you like it completely OO and pure MVC, Mach II is your thing. It follows the same evolution as Fusebox (most of the people behind both of the projects are the same). It started out as a Coldfusion methodology but a PHP version is out now.

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply