By Peter Bell

Processing .html files using ColdFusion - on a Mac or a PC

In the category of "post so I don't ever have to Google it again", here are the steps required to process .html files in ColdFusion . . .

[More]

An Evenings Craziness

So, I don’t love XML for config files (I know all the reasons they make sense, but a guy can have a preference, can't he?!), and I like my transient objects to know about their services, but I do like the idea of all of my configuration information in a single file, I need a good factory, and Dependency Injection sounds cool.

What’s a guy to do?

Well, I though it might be nice to prototype a very basic DI factory which is capable of lazy loading, is lightweight enough to use for all of your objects and which uses an included config file for people who swing that way. I wrote this in under three hours and it depends on a base class. It isn’t pretty, but I thought it was kinda fun. The code is up and running on a test project so it works.

[More]

Snippets: Extending the Generic Getter (and the hardGet() method)

In my last post I shared the design decisions and code for the generic getters I had previously enthused about. In this post I'll show how custom getters can easily be used to extend the business object with rules and I'll also share the currently fairly trivial code for the hardGet() method that encapsulates the pulling of data from within the iterating business object.

Lets start with a simple User object where you'd like to add a full name attribute based on first name and last name properties. You'd simply add a custom getFullName() method to your custom user object (which extends the base object) with the following code:

[More]

Snippets: A Generic Getter

I used to hate generic getters. Martin Fowler even has a term for people like me who don't think your beans should just go around sharing all of their properties (whether using generic, generated or hand coded getters). But then I realized how to create a smarter generic getter that would distinguish attributes from properties and allow for much shyer behavior and then I was sold on generic getters.

I love dynamic programming patterns. All other things being equal, the less code in your application, the eaiser it is to code, debug and maintain. Thoughtfully applied dynamic programming can drastically cut the amount of code in your application, making it much more maintainable and flexible. Imagine having a single generic base getter for all of your objects that would support information hiding, remove the need to test for existance, and that would seamlessly support overloading by custom getters where required. That's what I'm playing with here and it seems (so far) to be working very well . . .

[More]

Snippets: Creating and Loading a Base Business Object

I have looked at the code to create an iterating business object, as well as the code to display it.

This post looks at how to create and load such an object. Basically you just use a createobject() and then the loadQuery() method of the object, parameterized with a recordset returned from a DAO (my DAO's handle bulk operations as well as single records).

As an example, here is a very naive getbyUniqueAttribute() method from a base service object that allows you to create, load and return a bean using any unique attribute and a comma delimited list of one or more values. Please note that this is not a "safe" function, so it is a private method and just allows more specific methods such as getbyID() (another base method) or getbySKU() (a product specific method) or getbyEmail() (a user specific method) . . .

[More]

Snippets: Displaying an Iterating Object

In my last post, I described how to build an iterating business object to get all of the benefits I've been touting for a while. In this post, I look at how to use such an object to display the information in a view or a list . . .

[More]

Snippets: The Base Iterating Business Object

This is an extremely lightweight implementation of an iterating business object. All the methods are in my base business object so they are available to all business objects.

Please see my earlier post for the benefits an iterating business object can provide built up from first principles . . .

[More]

Snippets: SSL and the front controller

This is just a simple but useful snippet for managing the https status of various page requests being handled by a front controller based on some kind of action variable.

I'm not really a syntax guru, and I have heard there can be "gotchas" using cflocation, but this seems to work fine for me. Keep an eye out for the usual SSL gotchas: any resources with absolute non-https links (style sheets, images, javascript files, flash movies, etc) and forms going from secure action to non-secure action. Both will pop up warning boxes that your users won't like to see . . .

[More]

Snippets: Show me the Code!

It has been mentioned once or twice that I haven't been posting very much code. Truth is I'm more architect that programmer, and I've been much more focused on patterns than syntax, but in my new "snippets" section I'll be posting pieces of code that I've found of practical use rather than just as illustrative of patterns or principles.

Some of it will be very prosaic like the "SSL and the front controller" snippet I'll post tonight, but look out for a whole series on the business iterator and the other patterns I've been blogging about starting tomorrow morning (they're queued up and ready to go!).

BlogCFC was created by Raymond Camden. This blog is running version 5.005.