Value Object Bustifiers

  I’ve been fashioning Brian Renaldi’s the <a href=”; target=”_blank”>Illudium PU-36 Code Generator</a>  package to produce scaffolding for the Cairngorm framework.

People tend to have opinions about code generation, scaffolding being a euphemism for a specific portion of code generation.  I really like the dynamic scaffolding employed by Groovy/Grails and Ruby/Rails, wherin the functionality of the scaffolding is generated, but the code is not.  That seems pretty cool.  It would be Uber Cool to generate the entire application that way, and have no code except for that very special case stuff.  But even generated scaffolding serves its purpose, and helps a group development effort have some consistency.
Typically, what I do in my VO’s is have them accept a parameter that is of type object, and let the constructor act as a sort of copy constructor, if it is fed an object, otherwise leaving the default values.
A further item that is handy in scaffolding, is making the assignment case insensitive.  Coldfusion is case insenstive, and Actionscript, is case sensitive.  So those assignments can be troublespots sometimes.  Also, sometimes there may be a mismatch between the VO properties and the properties returned from the persistent store, so any mismatches are observed and traced to the console output.

To handle these items, I’ve added the following:

* Default constructor.
public function CategoryVO(data : Object = null) : void {
if (data == null) return;
var dataDesc:Object = ObjectUtil.getClassInfo(data);
var myDesc:Object = ObjectUtil.getClassInfo(this);
var props:Array =;
var myProps:Array =;
var found:Boolean = false;
for each (var name:String in props) {
found = false;
for each (var myName:String in myProps) {
if (!found &amp;&amp; myName.toUpperCase() == name.toUpperCase() ) {
this[myName.toUpperCase()] = data[name.toUpperCase()];
found = true;
if (!found)
trace("CategoryVO - Input Object has extra property " + name);

The business delegate layer I’ve seen done in a pretty boilerplate manner, where it acts as kind of a pass through layer to the Commands.  More correctly, any data conversion that may be platform specific, like Coldfusion or PHP related Object constructs, should be handled in the business delegate layer, isolating the platform details from the remainder of the Actionscript code.  That makes this layer a little more interesting for matters of code generation.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: