The Future Of ColdFusion As Blogged By Dan Vega

With commentary by yours truly...

I wanted to point everyone to a short series of blog posts by Dan Vega where he discusses the future potential features of ColdFusion as shown by Adam Lehman and Ben Forta at CFUnited 2008.

The Future of ColdFusion Part 1

The Future of ColdFusion Part 2

The Future of ColdFusion Part 3

Part 3 discusses the Hibernate integration that Adam demo'd during the keynote. I'm particularly intrigued by the prospect of this. For one, the implementation - although extremely early to speculate - looks very nice. I like the fact that it focuses on the objects themselves and not the database or anything else. I'm also intrigued by the possiblity of the object actually generating the database tables though I know some folks are skeptical of this kind of thing (gasp...what happens if I make a typo!!!).

I asked Adam what they had planned for complex objects and composition and he politically deflected the question as a "stay tuned", but since they asked about our feedback, here's how I'd like to see it work:

<cfcomponent displayname="User Component" extends="UserBase" output="false">
   
   <cfproperty name="first" accessor="true" hint="First Name">
   <cfproperty name="middle" accessor="true" hint="Middle Initial">
   <cfproperty name="last" accessor="true" hint="Last Name">
   <!--- complex objects (user has many possible email addresses) --->
   <!---
   emailAddress property would generate three methods:
   addEmailAddress (which would append an emailAddress object to the array of objects)
   getEmailAddress (returns an array of objects)
   setEmailAddress (sets an array of email objects)
    --->

   <cfproperty name="emailAddress" accessor="true" hint="Email Address" type="Users.EmailAddress[]" />
   
</cfcomponent>

Adam also displayed a simple method for retrieving the objects - and I don't remember the exact syntax, but it went something like this:

<cfset hibernate = request.getORMSession()>
<!--- get an object by it's id: --->
<cfset artist = hibernate.getById(artistID) />

To take this a step further, here is some psuedo code that I dreamed up:

<!---
returns an array of objects
whose first name is todd
syntax:
queryByAttributes([attribute],[value])
--->

<cfset artist = hibernate.getByAttributes('firstName', 'todd') />

What about multiple attributes/values?

<!---
passing multiple attributes
returns an array of objects
whose first name is todd
and last name is sharp
syntax:
queryByAttributes([list Of Attributes],[list Of Corresponding Attribute Values])
--->

<cfset artist = hibernate.getByAttributes('firstName,lastName', 'todd,sharp') />

What about sorting?

<!---
allows selective querying
by attributes and sorting
syntax:
queryByAttributes([list Of Attributes],[list Of Corresponding Attribute Values], [list of sort columns], [list of sort directions])
--->

<cfset artists = hibernate.queryByAttributes('firstName','todd','lastName', 'desc') />

What about accomodating multiple return formats? In this block I'm requesting that the data be returned in query format (which would in essence do a 'left outer join' type query where I'd have multiple rows for each object if they contained one-to-many data):

<!---
what about an optional returnFormat
argument (perhaps this should be
defined in the component - assuming they
are planning some sort of skeleton component)
syntax:
queryByAttributes([list Of Attributes],[list Of Corresponding Attribute Values], [list of sort columns], [list of sort directions], [returnFormat: query|array])
--->
<cfset artists = queryByAttributes('firstName', 'todd', 'lastName', 'desc', 'query') />

Wow so that's a lot of speculation and imaginative psuedo code. Most of it just rattled off the top of my head here, so if you disagree or would like to see a different implementation please leave a comment.

As you can probably tell I'm quite excited by this potential feature. I'm remaining a tiny bit pessimistic that the implementation will be what it needs to be given the history of generated code created by some of the Adobe wizards, but I think that those of us who are interested need to be very vocal on what we'd like to see. I also trust that the CFML steering committee will do this feature justice (if they are given input) and I know one or two beta testers who will be extremely hard on the ORM implementation to ensure that it is flawless.



Comments
Another possible implementation would be to pass a prototype object to the queryByAttributes method which would allow you to create a user object, set the various properties on that object (firstName and lastName) and pass the object itself - the queryByAttributes method would then return all matching items...
# Posted By todd sharp | 6/23/08 1:00 PM
Seems like passing in multiple attributes and values in list form would be problematic. Perhaps as struct instead?
# Posted By joshua cyr | 6/23/08 2:17 PM
Rails uses a pattern of find_by_column_and_column(value,value) so you'd say find_by_firstname_and_lastname('todd','sharp') - this could be done easily in ColdFusion with onMissingMethod().

I'm not sure I like that pattern tho'.

What about:

findByAttributes( { firstname = 'todd', lastname = 'sharp' } )

(assuming array/struct syntax was allowed everywhere).
# Posted By Sean Corfield | 6/23/08 2:19 PM
@Sean/Josh:

Yep I'm sure it could be polished. Passing a struct of attributes/values could be nice.

What about about passing a prototype object? Something like this:

<cfset user = createObject("component", "user") />
<cfset user.setFirstName('todd') />
<cfset user.setLastName('sharp') />

<cfset users = findByAttributes(user) />

Would match every user that shared the set attributes (this is partially how db4o manages querying).

Much simpler/cleaner, don't you think?
# Posted By todd sharp | 6/23/08 2:25 PM
I like the last comment example Todd. I guess I need to start blogging about some of this stuff, like how I tink server.cfc stinks in the current proposed implementation :)
# Posted By Adam Haskell | 6/23/08 7:39 PM
Adobe is listening - so speak your mind man! :)
# Posted By todd sharp | 6/23/08 9:51 PM
Thanks man.

A beautiful Site.

It help me to built my carreer.

Interesting series and many good points.
very nice blog.....

this site is nice and very helpful.

here is an another nice site <a href="http://web-adobe.blogspot.com">coldfusion</a>
# Posted By cfindex | 7/1/08 5:48 AM

Calendar

Sun Mon Tue Wed Thu Fri Sat
   1234
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  

Subscribe

Enter your email address to subscribe to this blog.

Tags

actionscript ajax blogging cfsnippets coldfusion flash forms flex funny stuff javascript misc model-glue off topic personal project learn slidesix sql

Recent Comments

Chinese Birth Calendar Accuracy Test
mama to be said: ok so i will be 2 months shy of 18 when i have my baby. this calendar does not technically work for ... [More]

Fixing 'User Profile Service Failed The Logon' on Vista
Mike said: That fix worked although all i did was remove .bak and reset state to 0. User was able to log in to... [More]

Chinese Birth Calendar Accuracy Test
Melissa said: Wrong for my daughter, which it predicted to be a boy... we'll see for #2. Predicts a girl (maybe, f... [More]

Adding Auto Generated Code Downloads to BlogCFC
fweerw said: http://www.ibiblio.org/st... http://www.cambodia.ait.a...... [More]

Check Out The New SlideSix
Todd Sharp said: Thanks for the feedback Ben & Rachel! I'll keep it all in mind as I tweak things over the next ... [More]

RSS


adobe community experts

coldfusionbloggers

FullAsAGoog MXNA

Consumed By Feed-Squirrel.com