Writing an Effective Gateway Object

The gateway object is a great way to separate your database calls into a container that could be easily swapped out in the event that you change to a different database setup and to make things a little more distinct and easier to understand when coding.

Assuming you follow the philosophy of the MVC frameworks out there, you’ve likely come across Beans, Services, DAOs (data access objects), and Gateways. Without getting too much into detail about what each of these types of components do, which I’ll get into in a future blog post, your gateway layer is meant to interact with your database where you need to do more than just create, read, update, or delete objects (which is what a DAO is for).

Read the rest of this entry

Making Bad Code Good

Following best practices is an easy way to keep maintenance costs down.

After listening to Dan Wilson’s session on Making Bad Code Good at cf.Objective() 2010, it really got me to thinking of some best practices that I wish everyone would follow in order to keep that maintenance period (which consumes a majority of a developer’s time and effort) as short as possible.

Read the rest of this entry

Playing with jQuery: DragForm Plugin

In an attempt to both learn how to construct plugins for jQuery, as well as learning some of jQuery 1.4, I’ve created the DragForm Plugin.

So what’s the point? Why create a plugin for dragging and dropping form elements? I thought I’d try a different take on the typical web-form usability and created what I think is a pretty decent alternative.

Drag and drop elements have been around forever. It’s a pretty good metaphor in terms of describing to the user how certain elements of a user interface are to function. The web is a different matter however. Drag and drop, while isn’t all that new to the web, it hasn’t been as widely adopted with how web sites are designed and are meant to be interacted with.

Read the rest of this entry

Faster Development with Mach-II’s View Tag Library

Mach-II offers several tag libraries to aid in fast application development. The view tag library reduces the time spent in writing mundane or complicated code in your views.

A major headache that many developers experience when coding their Mach-II views is the fact that they end up writing and re-writing the same (or similar) complex code in order to output simple elements like anchor tags or alternating row colors in a list or table.

Luckily, since version 1.8, Mach-II offers the view tag library to not only help reduce the amount of code required in each view, but make the code easier to read and look cleaner.

Mach-II View Tag Library

Read the rest of this entry

Search Engine Safe Routes in Mach-II

Search Engine Safe (SES) Routes are another great way of generating immaculate URLs using Mach-II which are great for SEO applications and making things just look cleaner.

What are Search Engine Safe (SES) routes? Take a typical Mach-II URL, e.g. /index.cfm?event=world&country=canada&province=british%20columbia&city=vancouver. Even using Mach-II’s own Search Engine Safe (SES), the URL remains somewhat ugly: /index.cfm/event/world/country/canada/province/british%20columbia/city/vancouver/.

Suppose the format of the URL is always consistent. In our example above it can safely be assumed that the event name is world which is followed by country, province, and city.

Search Engine Safe URLs with Mach-II

Read the rest of this entry