Web Applications Development Using Coldbox Platform

cortegesmashInternet και Εφαρμογές Web

10 Νοε 2013 (πριν από 3 χρόνια και 1 μήνα)

145 εμφανίσεις

Web Applications Development Using Coldbox Platform



Eddie Johnston

Department of Computer Science

University of Wisconsin
-

Platteville

Platteville, Wisconsin 53818

johnstoned@uwplatt.edu



Abstract


Web applications programming should not be difficult o
r time consuming. When developing in
a team setting, Coldbox framework makes it easy to have clear, concise, reusable code among
team members. Along with reusable code, coding principles can be set for a group of
developers. With this open source platfo
rm available for programmers, efficiency increases.
Not only does this Coldfusion platform help keep standards and code use, Coldbox also utilizes
key services and tools to help the developer with coding and testing. With services providing
great testing

tools, ColdFusion’s platform is perfect for projects dealing with complex testing.
With Coldbox’s modular approach, this platform touches upon concerns of application of
Coldfusion work.





What is Coldbox?


Coldbox is a framework that is most used f
or the development of web applications.
Stated by
Luis Majano, Coldbox developer, t
his framework is built around principles that endorse object
-
oriented practices and standards

[2]
. This framework is event
-
driven. Event
-
driven frameworks
use event
-
driven

programming, meaning there is a constant check for event detection. Once
there is a detected event, this event is handled. Another principle or architecture that Coldbox
framework is modeled around is model view controller architecture
, as indicated by
Adobe [1]
.
Another name for this model view controller architecture is MVC. Another key component to
Coldbox is that users work with codes and conventions as opposed to XML. Also, this web
application framework is based on code controllers.
According t
o Luis Majano,
Coldbox allows
for

unit

testing of the entire application

[2]
. This is the first web application framework that
allows for unit tests of the entire web application. The application features that are built with this
framework include bug re
porting, logging, caching, debug tools, and much more.



History of Coldbox


2


Coldbox platform was originally developed by Luis Majano. Majano is an author and computer
engineer of San Salvador, El Salvador. This origination took place in 2005. The dev
elopment of
this platform was meant for a multiple tier web application. July of 2006 was the time when
Coldbox platform framework was released as an open source framework. The developer, Luis
Majano, founded Ortus Solutions. This company creates and ma
nages software solutions for
ColdFusion applications. A team of developers now control, maintain and continue development
of Coldbox. This team is called Team Coldbox.
This information is listed by Ortus Solutions
[4].



Convention over Configuration


Another way to describe this framework is to say that is a convention based platform. This
“convention” term is also referred to as convention over configuration, or coding by convention
,
according
to Majano and Ortus Solutions at coldbox.com [2]
. Coldbo
x allows for developers to
make fewer decisions on
the configuration of the application.

For instance, if in the
programmer’s model there is a class called Products, the related table would, by default, be
labeled as “products.” The benefit of having con
ventions, or generated configuration files, give
developers quick and flexible code. This already
-
written configuration permits less decision
making of the developer and easy code reuse. Earlier web application frameworks described
configurations of appl
ications with XML files.
As stated by Ortus Solutions,
The type of
description in the XML can include describing fields in databases and the relationship among
fields or databases

[4]
. Convention over Configuration importance is proven by production time

and cost cuts for development teams.



Custom Conventions


Coldbox also allows for custom conventions.

As presented by Majano, t
hese conventions allow
for customizable web applications

[2]
. Coldbox will know where to locate these conventions in
a dire
ctory designated for conventions. From the directory, Coldbox can execute the correct
convention. Programmers and developers can create custom layouts, handlers, and configuration
files because of custom conventions.



Debugging tools


As stated before,

Coldbox platform framework is the first web application framework that allows
for an entire unit application to be performed. The debugging console, which can be displayed
right in the browser of choice for the developer, gives plenty of information

on

w
hat is
happening at certain defined points of the test and session life of the application. The debugger
uses methods that support smart caching allowing developers to time events, handlers, a
nd code.
This is presented by Luis in his instructional videos

located at carehart.org [2].

This smart
caching is displayed in an easy to read manner for the testing of the application. Such examples
of information displayed back in the debugging console can be monitoring of variables
3


throughout the framework. Als
o, information on execution time of framework methods is
illustrated very easily. The request collection can be examined
by

debugging traces within
framework methods to check the status of data within the request collection. The debugging
console of Cold
box framework is once again, like many other features of the framework, very
customizable
in terms of

what data to view and monitor. This is merely skimming the surface of
the very powerful debugging utilities of the Coldbox framework.



ColdFusion Mark
up Language (CFML)


To truly understand this Coldbox Platform framework, we should look at the language by which
this platform was developed. ColdFusion Markup Language is a scripting language created for
web development. This language is commonly called
, CFML. CFML can run on common
engines such as Google App Engine, .NET Framework, JVM, and much more. Open source
execution of CFML engines exists as well, such as Adobe ColdFusion, Blue Dragon, and
many

more.


ColdFusion Markup Language can supplement

standard HTML code and files with its own
commands that include database directives, conditional operators, formatting functions, and
other features to yield web applications and services
, as indicated by Majano is his tutorial
videos

located at carehart.
org [2]
. CFML provides its own version of objects, CFCs. CFCs, or
ColdFusion components, give the developer tools to separate business logic from code and
presentation. CFML can also be used to generate code in other languages
,

XML, JavaScript,
CSS, an
d HTML.


CFML engines are created to handle certain files with specific extensions. These extensions
include .cfm and .cfc files. The ColdFusion files are passed to the CFML engines for processing.
The engines only process CFML tagged items in the fil
es. The rest is returned to the web server
unchanged. CFML engines are designed with compatibility in mind.


CFML syntax is very similar to other web scripting language. The CFML language uses angled
brackets similar to HTML, which is shown below in Fi
gure 1.






Figure 1: Query example


<cfquery

name
=
"Classes"

datasource
=
"#ClientDatasource#"
>

SELECT

*,

Locations.Location

AS

LocationName,

ClassCategories.Category

AS

CategoryName

FROM

Classes

INNER

JOIN

Locations

ON

Classes.Location

=

Locations.Locati
onID


INNER

JOIN


ClassCategories

ON

Classes.Category

=

ClassCategories.CategoryID


WHERE

StartDate

>

#
NOW
()
#
AND

Display

=

'True'

</cfquery>


4




The above figure shows how CFML handles query functions. Distinguished tags as seen above
help CFML engines te
ll

what

code to process and what code not to return. The “cf” portion of
the tag is what defines a ColdFusion tag from other scripting languages. The “#” sign at the
beginning and end of a value allows CFML engines to render the values as an output.


O
ther language extensions are available through custom tags that can be developed by a
programmer. These custom tags are ColdFusion files that are to be summoned as tags. In this
sense, CFML allows for flexibility. Also, the Coldbox framework handles the
se custom tags
without a problem, which is another benefit of this platform. The custom tags are placed in a
common directory and are invoked using “cf_” then the file name of the custom tag without the
extension.



Model View Controller Architecture


M
odel View Controller is a software architecture. The logic behind MVC is separation. MVC
can be manipulated with many different designs depending on the logic of each framework. For
the majority of the time, the general flow remains the same.


The flo
w of MVC is as follows: A user of some sort, whether it is a human or some type of
service accessing the web application, invokes the application by an event or any other type of
command. At this point, the controller handles this event or input from a us
er. The controller
translates the event or command into an action. Now that the action is within the controller of
the MVC model, the controller informs the model of the user request. The model may or may
not change its status depending on what the user
request contains. The next step is vital to how a
user sees information. A view can then take what it knows from the model to display appropriate
data. Depending on the type of framework, this step of manipulating data from the model to
view can be diff
erent. After the view is sent to the user, the entire process is restarted by waiting
for a request from a user.



Figure 2
: how MVC functions.













Client

Model

View

Controller

D
B

5




Key Ideas of MVC


The key idea of MVC is to decrease complications in design by
the use of separation of the
model, view, and the controller.
As Microsoft points out, f
irst, the architecture uses the model to
manage the performance and data of web applications

[5]
. The model responds to the request
usually through the controller. T
he model may also alert the view of the state change of the
model if one occurs. Next we have the view. The view renders the model into what would be
acceptable for the user interface. The view is not limited to one per model though. A model may
use mu
ltiple views for different purposes,
e.g.
, phone apps or

Internet

browsers. One of the most
important keys to MVC is the controller. The controller retrieves data or collections of data and
communicates with the user, model, and view.

MVC

is essential f
or quicker production, which
leads to quicker profit for development.



Benefits to MVC


Model View Controller Architecture brings advantages to developers and its frameworks. A
crucial benefit to MVC is the separation of View, Model and Controller. Th
e view is separate
from the model, which means there is no dependency from view to model or view to controller.
The user interface can display many different types of views depending of the request collection.
With the many different views being rendered
, the model and controller are not manipulated due
to the separation of logic. The separation of logic allow
s

for ease of control among the
framework that uses this type of architecture
,

in this case, the Coldbox platform using MVC.


Changes to each elem
ent of MVC can be made without affecting other elements of MVC. Code
management of a view or layout can be processed without touching or changing the business
logic, or model. The data rendered to the view can be untouched when changes to the view are
ma
de. This is very important as technology changes and code maintenance becomes more and
more important every day. For instance, a web browser can display data to a user interface. A
development team might need to make a website or web application viewabl
e to a user without
changing the one view and using the same data the other view uses. With the MVC idea in hand,
a developer can now develop a new view or layout to accommodate for changes in technology
without changing the model, data, controller, or an
y other views already in place within the
application.



How Coldbox Platform Uses MVC


Coldbox Platform utilizes MVC in its own way. The basic general concept is still intact with
Coldbox, but the way Coldbox framework was developed on this architec
ture differs from other
frameworks.
As stated by Majano in tutorial videos, such as “Down and Dirty with Coldbox”,
found at carehart.org, a

user or service still sends a request to a “request collection.”
From

here,
the data or information calls upon the
controller or view depending on the event or action
6


required from the collection of data. Within the controller, plugins, event handlers, and
interceptors use the request collection to call upon the model if needed. After the controller
depicts what the
request collection needs, the controller manipulates data for the request
collection to call upon the view. From here, the view can use a layout, if requested, or plugins to
display data to the user interface in an appropriate manner

[2]
. Figure 3 repres
ents how MVC is
used by Coldbox.


Figure 3
































Request Collection


The request collection,
or RC
, shown above in figure 3, uniquely represents the user request.
This

RC

is more than just a data s
tructure; it is an object of CFML.
This idea comes from
Majano, as represented in “Down and Dirty with Coldbox” [2].
This RC
,

lives during the request
scope of the web application. In other words, the RC is not saved after the application ends the
sessio
n with a user or service. The framework can access this request collection at any point of
Request Collection

Event Handlers

Plugins

Layouts

Views

View

Controller

Model

Plugins

Model Business Layer

Interceptors

7


the application life, i.e. interceptors, plugins, handlers, views, and layouts can work with the
request collection to deliver what the user wants. The request col
lection is a very easy way for
the Coldbox framework
to

set values into it and get values from it.


Event Handler


A ColdFusion Component that allows a command to be converted to an action is the event
handler. The event handler, in a nutshell, gives
th
e

ability to tap into the framework.
ColdFusion events are public or private methods. Any method created in the controller will be
registered as a Coldbox event. The way that these events are registered is through conventions.
Event handlers are very
customizable and a key component to the Coldbox framework.



Plugins


A plugin is also a ColdFusion component. Plugins help extend the functionality of the ColdBox
platform. Plugins are also customizable. Coldbox locates all plugins in a directory to
organize
and gain access to these plugins. Plugins can be used throughout the framework, as well as in
the debugging console to display data how a tester would like. Plugins are a helpful way to
make development more efficient for Coldbox.



Views and
Layouts



Views give Coldbox platform an easy way to render information and data to a user interface.
Once again, like most features of Coldbox, both views and layouts are very customizable. A
developer can easily create their own layouts or views. Vie
ws do not need to be rendered with a
layout, but can make things cleaner and

more
efficient in coding standards among a development
team.



Conclusion


To conclude, Coldbox platform is a great framework for developing web applications. This
framework le
ts developers have reusable code among team members that follow standards and
good coding practices. Not only does Coldbox keep organization a key feature, but this platform
also exploits services and tools to not only develop web applications but also al
lows for unit
testing of the application. This ColdFusion framework is ideal for projects that need complex
testing. To be clear, Coldbox platform framework is more than just a MVC framework
;

it is a
software tool and foundation for development.



8



Re
ferences


[1] Adobe Systems Incorporated. "ColdFusion Developer Center | Developer Connection."
Adobe
. Web. 15 Sept. 2011. <http://www.adobe.com/devnet/coldfusion.html>.


[2] Arehart, Charlie.
Charlie Arehart ColdFusion Consulting Training Troubleshooting

Tuning
Configuration Support
. Web. 10 Sept. 2011. <http://www.carehart.org/>.


[3] Majano, Luis, and Ortus Solutions, Corp.
ColdBox Platform
-

Defining Enterprise
ColdFusion Development
. Web. 10 Sept. 2011. <http://www.coldbox.org/>.


[4] Majano, Luis.
Ortus Solutions, Corp
-

A Software Revolution
. Web. 13 Sept. 2011.
<http://ortussolutions.com/>.


[5]
"Model
-
View
-
Controller."

MSDN â
€“ Explore Windows, Web, Cloud, and Windows Phone

Software Development
. Web. 01 Oct. 2011. <http://msdn.microsoft.com/en
-
us/library/ff649643.aspx>.