By Peter Bell

When to Make your Own Types - a Nice Introduction

It isn't new, but this PDF from Software Magazine provides a nice concise view of some of the benefits of what I call custom data types.

Unfortunately, implementing these in ColdFusion is a bit of a pain only due to the cost of object instantiation, so my best solution to date is to "hack it" using a DataTypeFacade singleton and getting my business object to delegate most property specific actions to that facade which in turn calls the appropriate data type (so I have singletons for DateTime, SSN, PhoneNumber, etc.). That works pretty well in practice.

How do other people implement custom data types in their CF applications?

[Why a facade? Because I don't want to have to inject 50 different data types into each transient business object - I feel it is cleaner to just inject a single facade - especially while my API is still settling down.]

Generating 80% of your applications: Step 1 - Implementing Custom Data Types in ColdFusion

I love the idea of scaffolding. The more routine work that the computer can do for me (especially in terms of CRUD), the better. But the biggest complaint most people have who have used scaffolding is that they usually have to replace it for production because the code is too naive.

If you look at most of the reasons you have to replace scaffolding it is simply because you know that a field is a phone number or an age rather than a string or a date time (which is all the database knows) and you typically want to apply more specialized form fields, display rules, transformations and validations. The solution is to improve scaffolding with Django style custom data types rather than Ruby on Rails style database metadata.

So, why not have a system that just allows you to describe custom data types in terms of their form fields, display rules, transformations and validations and then simply define all of your object properties using those custom data types? That is exactly what I have been doing for the last few years in my application generator, and I’m currently in the process of trying to upgrade the way this works to make it a little more OO.

[More]

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