By Peter Bell

E-commerce – Orders and Addresses

The thing I love about building even very simple e-commerce applications is that they can bring up sufficiently complex classes of design problems to make them a great testing bed for new ways of implementing web applications. Today I want to look a little at the old “orders and addresses” problem to see if it can provide any more generalized insights into Object Relational Mapping . . .

[More]

One Service Class Per Business Object - Not as Bad as You Think . . .

For a while I've noticed that a number of people who I respect in the ColdFusion world recommend that you not reflexively have one service class per business object. I want to suggest that actually it's a pretty useful default approach - especially if you want to develop consistent, maintainable applications - quickly and cost effectively. As always, looking forwards to feedback . . .

[More]

How Many Classes Per Business Object?

How many class files should you have per business object? In Smalltalk and Ruby, the answer is often one. I'm finding three is working pretty well for me - here's why . . .

[More]

The Death of the Gateway?

It is interesting to see the change in tenor on the mailing lists recently when discussions turn to DAOs, Gateways, Service classes and the like. I won't say the Gateway is dead, but when I say it's feeling unwell, I'm thinking of Soviet era Russian premiers as I think about it . . . :->

[More]

Do YOUR web applications lie?

I noticed a posting on the Scottish CFUG about AOL and session problems and it got me thinking about sessions, the meaning of URIs and whether we're building websites that lie . . .

[More]

Logging Content Access

A client recently wanted to be able to see exactly who had viewed what articles, pages and categories in their site. I thought it might be worth taking a little time to specify and implement a generalized solution which we could then just offer an option as part of our software product line. . .

[More]

What I Need From My ORM/Data Access Layer

The ideal ORM is dependent on your exact use case. From Transfer and Reactor to SQL Alchemy and Hibernate, there are many ORM systems available of varying complexity. Here's what I need from my ORM system. I'd appreciate any input on features I haven't mentioned along with a sense of the problem they solve. This spec works for me today, but I'm sure there are plenty of new use cases just lurking out of site that I haven't thought through yet :-> . . .

[More]

Migrations vs. Schema Definitions - It Matters More than You'd Think . . .

I was just thinking about how Rails does db schema migrations and how I generate my db schemas from a collection of XML object models and I realized that a fusion of the two approaches would allow for some pretty cool automated refactoring of code, schemas and data . . .

[More]

Looking at Lists

I'm doing a review of my in-house framework. As part of that I plan to do a number of posts looking at common functionality required by web applications (lists, views, forms, imports, exports, reports, etc.) and generalized, configurable approaches to solving the problems. In this post I'm looking at how to handle the getting and displaying of a list.

[More]

IBO Sample Code

I created a project for the Iterating Business Object some time back but never got a chance to upload code as my iterating business object is firmly embedded into my in-house framework so it doesn't really exist as its own bean.

After some pressure I finally uploaded a ZIP file to the project. It is just a single cfc with all of the key methods and I haven't had a chance to test it on its own, but it should give a pretty good idea of my implementation for anyone who wants to do something like this.

Two design decisions that are most arguable (IMO):

  • There is a question as to whether a business object should really know how to iterate itself - it might make more sense to have a separate iterator or at least to compose the iterator. While true in practice, when you try to implement this (without actually creating an array of beans) the implementation gets a little messy. I think a cogent argument could be made for decorating business objects with an iterator instead of having base business object methods for iteration, but this is working for me, so I'm not in a rush to change it purely for architectural purity (although I may play with that fairly soon).
  • The next() iterator method is both a command and a query, incrementing iterator and returning a boolean with a 0 if there isn't a next record. I think there is something to command query separation, but this simplifies my iterator interface allowing for the code snippet below to work, so I'm happy with the hack.

<cfset ObjectList.reset()>
<cfloop condition="#ObjectList.next()#">
#ObjectList.get("Title")#<br />
</cfloop>

Of course, you could argue with the whole generic getter/setter approach as making the API of the bean less explicit, but for my use case there's no way I'm going to generate a bunch of dumb getters and setters to bulk up a code base that human beings really aren't supposed to be looking at most of the time anyway.

Then there is the question of why bother with this at all rather than just a collection of actual business objects. Answer is instantiation costs for displaying lists and by having a performant approach to instantiation what appears to be a collection of business objects it means I can ALWAYS use the same approach rather than having to start with queries and then refactor my views and other code as I find a business object has more calculated properties than I realized.

Thoughts?

More Entries

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