Tuesday, March 04, 2003

The Data-Driven Framework (or DDF) for ColdFusion

Get the Source Code!

In general, a development framework allows programmers to focus on the unique aspects of an application. Many frameworks have been developed over the years - even the Radio Shack Model I; back in 80's had a framework to make adding new DOS commands easy (provided you knew assembly language). Microsoft developed a framework called MFC for Windows. Today there are several frameworks for ColdFusion; CFObject and Fusebox are perhaps the most well-known.

Language Independence

I freely switch between several languages (Java, ColdFusion, and Perl being my current favorites) on a near daily basis. Therefore, the framework that I use should be able to be duplicated in any language.

Application Independence

The application code should be totally unaware of the framework. When a developer sits down to create a feature or to maintain code, she should not have to worry about what the framework is doing. In other words, the framework should be loosely coupled to the application.

Simple

Since I work in so many different environments I want to use a framework with as few rules as possible. I don't want to remember a large set of guidelines as I'm coding. No programming "tricks" that need explaining should be used.

Generic

All code in the framework should be relevant for *all* situations. Application-specific code should be delegated to include files. And those files should be generically named like [application]_init.cfm or [application]_pre_action.cfm or [application]_post_action.cfm.

Data-Driven Decisions

Whenever possible, function points in an application should be replaced by dynamic data. For example, instead of a switch or if statement to determine a hard-coded color, use a hash table (a structure) with the switch expression as the key. This approach can potentially increase the scalability of your program, but more importantly increases its flexibility. During run-time, a new hash entry can be created to accomodate a new value for your expression. If a switch statement is used, a new version of the template needs to be coded, tested, and released.

Sometimes predefining data is not possible, and that's ok. Also sometimes the various combinations of parameters such as security and time-of-day are too complex and using an algorithm is better then using data. Obviously some programmer judgement will be needed.

Post a Comment