Adobe is making our life hard in ColdFusion 9 ORM
Tags: Coldfusion
After having a bit of a discussion with one of the Engineers, I set out to prove this engineer wrong and I did just that. I won't go into specifics on that just yet, as I have more tests to run. But the one thing that I want to point out is that ColdFusion claims to be RAD. And I am going to show how the ORM side of ColdFusion 9 is not RAD, and it requires you to code more than it should.
I will be making this comparison against how I would do this in grails, I have had this discussion with this particular Engineer in Adobe and the one thing that seems to be consistent is that Adobe are not prepared to change this behaviour.
So lets look at a very simple grails or as it should be called GORM to create a very simple database.
static hasMany = [pages: Page]
static constraints = {
uniqueUrl(nullable: false, matches: /[a-zA-Z_0-9\-]+/)
}
String uniqueUrl
String name
}
Now the first thing I need to explain here is that you will notice that there is no primary key, or ID field defined. In grails if you don't specify this, it will automatically be added. I won't go into more detail on this as I have raised an Enhancement request for ColdFusion to do the same.
You will also notice that this is also setup that the space has many pages, and that the entiry / Domain Class is called page.
If we look at the Page Domain Class from Grails.
String name
Space space
}
All we see is that that again the ID is not specified, so again the PK is auto added to the database. And we can also see that we have a link to Space. Now this is important, as grails knows that we are going to have a one to many relationship here. Because the page Domain Class has already defined that it contains many pages.
Now lets look at the same thing in ColdFusion, and you will notice that not only do we have to specify more but in reality we end up having to be more specific and this is what I call being counter intuitive and not what RAD is all about.
If Adobe is going to be serious about being RAD the engineers need to look outside the square, and stop being dogmatic when it comes to solutions to make our lives easier. And this particular engineer in Adobe has made it very clear that Adobe are not interested in making our lives as a developer, easier. Which I don't understand, because at the end of the day if we require to type less, then we are what you call being RAD.
So how would this look in ColdFusion 9?
property name="page" fieldtype="one-to-many" cfc="page" fkcolumn="id" cascade="all";
Now you will notice that we have defined the unique url to that of what matches Grails here, but you will also notice that we are forced in some circumstances to include the fkcolumn. In Grails if the Database is not one that supports FK's, grails will take care of this for us. In ColdFusion we will get an error and the application will not run.
But the most important problem, ok its not a problem, but is counter intuitive and makes our job harder because we as a ColdFusion developer have to type more code.
So if you are or have used grails and come to ColdFusion, you are no longer developing in a RAD environment. Adobe will claim that the application called ColdFusion is RAD and promotes this, but here is an example where a certain engineer will not admit, that this is much easier to code and refuses to acknowledge that this should be considered as an enhancement.
Now before I give you the enhancement that we should be getting, lets look at what we are forced to write in ColdFusion as it stands now.
Now you will notice that again we are forced to provide the fkcolumn for those databases that do not support FK's. But the thing is that remains unclear why Adobe don't see this as great enhancement. Is that you are also forced to proved the relationship yourself.
So even though I have tried in the past to get this enhancement approved, what would it look like if Adobe was to approve it?
Well for starters the page would look like this.
property name="space_id" fieldtype="many-to-one" cfc="Space" fkcolumn="space_id" cascade="all";
You will notice that I did not include the ID field in this, and the reason is that if it doesn't exist then ColdFusion should be smart enough to just include it.
And the space entity would look like.
property name="name" ormtype="string";
Did you notice how I did not include the relationship that Adobe has forced us to include?
The major problem is that until Adobe provide us with Spring under the hood, and where we can leverage of this in the code we are forced as a developer to type more, provide more attributes and relationships that what we should have too.
The one thing that I have campaigned here is that we should be typing less, not more. And until this changes I will continue to claim this as not being RAD at all.
Because I should be able to do what grails does, show that I want to include an injection of Space into pages. And space shows that it has many pages.
ColdFusion 9 ORM is still young, and needs a lot of attention and improvements. This is just one that could be added by Adobe to make our lives a bit easier.
-
ColdFusion and Grails are not the same thing.
# Posted By Tony Nelson | 3/5/10 8:47 AM -
@Tony, that is very true. But it does show how we are forced to type more.
# Posted By Andrew Scott | 3/5/10 3:11 PM -
But you're essentially claiming that ColdFusion isn't RAD because it doesn't function exactly like Grails. I don't know about you, but if I'm able to write a pretty robust application in a short amount of time without writing a single line of SQL, that still qualifies as being RAD.
# Posted By Tony Nelson | 3/5/10 3:33 PM -
No Tony I am not.
I am using grails as an example because it doesn't require all that extra information.
So RAD as we all knows means Rapid Application Development, which basically means that don't need to type as much as other languages.
I am not saying that ColdFusion needs to behave like Grails in any way shaoe or form, I am simply saying that there is a RAD language. ColdFusion on the other hand is forcing us to do more typing, and that is not what I consider to be RAD.
The less I have to type in ColdFusion the better, and the point I am trying to make here is that the FKColumn should not be a required field. And that the name attribute should indeed be the name of the field in the database.
Why do we need to specifiy another attribute to name that field when we already have the name attribute, the fkcolumn is not needed and is essentially another attribute that we shouldn't need to type.
Hence the reference back to grails, does that make more sense?
# Posted By Andrew Scott | 3/5/10 5:19 PM



TweetBacks