As much as people think I’m a jerk, I’m a jerk for a good reason. I’m not afraid to stir the pot or call people out and I expect them to do the same to me.

Back on Feb 29, Ben Forta posted an entry to his blog about how the updater that was to be released for CF8 would fix the nesting problems that implicit creation had. If you haven’t already done so, take a minute to read the posting and the comments.

If you read through the comments, it was asked by Hansjoerg if the updater would fix the implicit creation problem where you couldn’t directly pass an implicitly created array or structure to a function. I noticed that 5 days went by with no answer, so I reiterated the question and again, got no answer from Ben. At this point something told me that it wouldn’t be fixed.

Today the updater was released and I ran to download and try it out. I hoping that I would be made a jerk of and the function call bug would be fixed…. it’s not.

Here is the function I used for testing:

<cffunction name=”testing” access=”public” returntype=”void” output=”true”>
<cfargument name=”a” type=”struct” required=”false” default=”#structnew()#”>
<cfdump var=”#arguments.a#” label=”argument”>
</cffunction>

Pretty simple. It just takes a structure as an argument and then dumps the contents to the screen. With this in hand I tried the implicit creation.

First off, implicitly creating the structure as a variable and then passing it into the function:

<cfset s = {a=4, b=[1,2,3,4]}>
<cfset testing(s)>

Hey it works! But I figured that it would. So now the really issue at hand, passing an implicitly created structure directly to the function:

<cfset testing({a=4, b=[1,2,3,4]})>

It failed.

Hell I even tried:

<cfset testing(#{a=4, b=[1,2,3,4]}#)>

and

<cfset testing(”#{a=4, b=[1,2,3,4]}#”)>

just for kicks. They all failed… the bug still exists.

This is what pisses me off, every other language out there allows you to do this, but you can’t do it in CF. We try to bring this to the attention of Ben Forta ( our evangelist, you know the guy who’s suppose to listen to us and address our concerns) and even directly to Adobe by submitting a bug report (thanks to Ben Nadel) and still we’re ignored.

I would rather have had Ben and / or Adobe tell me flat out that this issue wasn’t going to be resolved in this updater, then just ignore the question all together like they did.

I guess we’ll just have to wait for CF9 to see if this gets fixed or not?

The war on beans

April 2, 2008

I’m declaring war on beans. I can’t for the life of me see why they are used and I want someone out there to give me an intelligent answer as to why you should even bother using them.

Here’s my argue for getting rid of them.

For some odd reason, some bright boy a long time ago though that we should break apart the DAL (data access layer) of our application into 3 classes for each table in our database. You had a bean (which had getters and setters), the dao (data access object which contained the CRUD methods) and a gateway (which I was told was for general queries against the table).

Now using this approach, you would load your daos and gateways into the applications scope so that they persisted and were only called once. Then you would use your beans to populate the data you wanted to pass to the dao or gateway and then pass the bean to the dao or gateway.

I find this stupid.

For one it sucks because if you need to make any changed to your dao or gateway, you have to reload your application in order for the changed to take affect. This really can become a nightmare during production as it lock the application scope until all the changed are loaded.

The other point is that now every time I create a new dao or gateway I have to remember to write some code to load it into the application scope. I’m a forgetful person and I can see this causing a problem.

Then there are those that claim that using an approach like this can give your app a performance increase since you’re not constantly creating and destroying objects all over the place. Personally, this is a lie told to us to sell us on the idea. I have never seen a performance increase in an application using this approach and isn’t creating a bean still creating an object?
My whole argument calling for the end of the bean is the plain fact that they are useless when you use an approach like the one table per class design.

When using the one table per class design, you have your getters, setters, CRUD, validation and queries all in one class. By following this design you instantiate the class each time you want to use it, inject the values into the setters and perform the action you want on the class. To me this makes developing and maintaining an application much easier.

For one I don’t have to load a ton of crap into the application scope. Second, now if I need to make a change to a method I don’t have to reload the application and cause a stand still in my application until the action completes. Third, it just makes sense.

I never understood why people would want to create a bean and throw a bunch of values in there and then have to call a whole other class to perform the validation and action. Sure you can put the validation method inside the bean, but that’s not really the purpose of a bean.

So I ask the world…. Why do people even use these things and do they really make an application more maintainable? Personally editing, seeing and tracking the logic in one file is a lot easier then doing it across three files.

Don’t even get me started on TOs.

CFDOCUMENT and HTTPS

March 24, 2008

So we had to install an SSL cert for one of out clients. Low and behold the client goes to print out some badges and the images don’t want to show up. First words out of my mouth were…. “MOTHER FUCKER, GOD DAMN CFDOCUMENT!!!”

Yes kiddies, that’s right CFDOCUMENT doesn’t like SSL.

The solution (which sucks) is to make sure you put the full NON-SSL URL link inside the document. Make sure that you do this also for any CSS that you are including, because that will brake also.

In case you missed it, BlueDragon (the J2EE version) is going open source as announced by New Atlanta earlier this week. This announcement has singled handedly fired up the CF community. I’ve been hoping for so that the Smith Project would take off and become the front runner of CFML engines since it was the only open sourced one at the time. Alas the project has been plagued with little enthusiasm from the CF community since it doesn’t support a lot of features and many just don’t want to contribute.  BD on the other hand is feature rich and ready to go.

But let’s take and step back and look at what this could mean for other languages and frameworks out there. What could the other get from BD going open source?

For one thing, I’ve always wanted to just ditch CF and get into Rails, but there are some feature in CF that I just can’t get away from. I think the biggest is document generation with CFDOCUMENT. I can’t tell you how many clients I have using this feature to print invoices, attendee badges and other things. CFDOCUMENT makes it so easy to do. Trying using PDF::Writer in Rails to print an invoice, you’ll probably shoot yourself. This is one feature that the Rails community could look at and port into Ruby and ultimately include it in Rails.

Personally I think the open sourcing of BD was a very bold move by New Atlanta and will undoubtedly help get CF in front of more people. Kudo to Vince and the team for stepping up!

Can’t wait for the download.

On Friday, Ben Forta posted to his blog that in the next updater for CF8 we will finally be able to nest implicit creation of arrays and structures. This comes almost a full half year and two service packs since CF8’s release.

Implicit creation of arrays and structures was probably the most anticipated update in CF8. For a long time, many developers that use other languages have always laughed at CF because of the lack of such basic features in the language such as implicit creation. Really, can we blame them for laughing. It’s such a pain to write line after line of function calls just to create an array or structure.

When CF8 was finally announced that it would include this feature, I was jumping up and down, finally we were catching up with the rest of the bunch. Then it was announced that you couldn’t mix the implicit creation syntax and again my heart dropped and once again I felt cheated.

I don’t know why with every major release of CF since version 5 there has always been this MAJOR, COOL new feature that will be included only to have it poorly implemented. If you sit back I will take you for a walk down memory lane and prove my point.

CF5 finally gave us hope of creating our own user defined functions (UDFs). Before this feature you had to use custom tags if you wanted to encapsulate functionality. If you saw code written before the CF5 days, it was littered with many custom tags to such simple things. This was also the days when CFX tags were wildly used in applications. Many people loathed the implementing of CFX tags in their applications since they were notoriously not thread safe and required you to use CFLOCKs around them to prevent collisions. Coupled with the fact that it was damn near impossible to convince your hosting company to install it on their servers.

Once CF5 introduced UDFs everyone thought this problems would be solved. However are glee turned to anger when we found out that you could only create UDFs within a CFSCRIPT tag which made using tags to create UDFs impossible. Why even bother to include this feature in if it wasn’t completed? Not until the release of CF6 and the CFFUNCTION tag did we finally get full UDF creation using all tags and functions of CF.

CF6 was touted as a new era in CF history. The was the version written from the ground up in Java as opposed to the old C++ code of earlier version. With this new version the biggest feature was the ability of running separate CF instances. This meant that if you had a bad application on a server, you could isolate it from the rest of the other application by creating an instance for it.

We all know what happened though. There was no simple way of creating instances and you could only do it if you bought the enterprise edition. Until CF7, that include the instance manager within the CF Administrator, if you wanted to create an instance you had to create folders and copy and edit files. 9 times out of 10 you screwed up creating the instance, so you had to start all over. It was just a mess.

To add insult to injury, CF6 was dog slow when it came to development. Each page was complied and then the byte code was saved to the drive. This meant for every change you had to wait upwards of 30 seconds for your page to compile. Editing minor changes took hours and CF for the first time lost it’s RAD (rapid application development) feeling.

Even worst was the fact that most people opted to downgrade their servers back to CF5 making CF6 Macromedia’s VISTA. Only after CF6.1 was release months later did things start to get better, but by then it was too late and most shops migrated over to PHP or ASP.NET. What little market share and respect CF had was chipped away again.

CF7 brought us the feature that most of us use everyday and probably couldn’t do without. This was the release where the IsValid() function was born. No longer did we have to depend on a library of function in order to valid input, it was done in a simple and easy to use function. CFDOCUMENT was also introduced making CF the first language to have the ability to print webpages to not only PDF but even FlashPaper. CFREPORT was one the big onces though. This was the first time that you had to use an external application, called the CFREPORT Builder, you utilize a feature of CF. CFREPORT was said to solve the problems of hand writing reports by giving us an Access like interface to build our reports. All and all these 3 features would surly make up for the mistakes made in CF6 and win back abandoned.

History has this problem of repeating and sometimes repeating too often.

CFDOCUMENT was and still is plagued with problems and even after numerous updates, they still exist. Translating HTML tables has always caused heartache and trying to style your output was a crap shoot at best.

CFREPORT just didn’t work. The report builder that was shipped on the CF7 CD wouldn’t even install. If I remember correctly it was several weeks after that Macromedia finally out a version of the report builder that you could download and install. Even after the update, the report builder was extremely buggy to be useful. Many people, including myself, have altogether sworn off CFREPORT and vow never to use it. A great idea that just failed.

IsValid worked like a champ, except with integers. Problems still exist in CF8 where telling IsValid to validate an integer yield weird results. The only work around is a combination of int(fix(val())) on your variable and then validate it as a numeric data type. If only a little more testing was done.

Which brings us current with CF8. Again the parent company, Adobe this time, tease us with new features only to implement them poorly.

Which is why I ask… What will be poorly implemented in CF9?

I’ve been wanting to install this for awhile since I’m doing all my development now in CF8 and want to take advantage of the new syntax.

There are two versions I found on the net: one from Mark Drew and one from Adobe. Neither of them had the cfloop array parameter. Someone was kind enough to post how to add it to the dictionary and I did just that. Since it looks like no one wants to update it, I’m volunteering.

You can download the dictionary file by clicking here or from the box.net widget.

To install, simple copy the file to the following directory and restart eclipse with the -clean option:

<eclipse install folder>plugins\org.cfeclipse.cfml_<version number>\dictionary

Any additions and / or corrections are welcomed. Just leave them in the comments below and I will add them with 48 hours.

Updates:

02/16/2008 : added cfdbinfo tag

ColdFusion 9: CGI.HTTP_ADDR

January 21, 2008

The CGI scope that CF returns for each request is extremely useful. Imagine not have this scope and having to use Java or some other trickery to get the information you need, you would probably end up going nuts.

There is one piece of information missing however that I only now I realized wasn’t there. Currently this is no variable within the scope that returns the ip address of the server.  The closest variable that the CGI scope has is the SERVER_NAME variable. Supposedly the variable will return the ip address of the server if the server’s name is not resolved. However you can’t tell it to not resolve it in anyway and always return you the ip address, hence it’s not reliable. The only ways currently to get the server’s ip address are to just know it or use the GetHostAddress() UDF that Ben Forta wrote.

With all that blabbing I just did, what I’m trying to say is that the next very of ColdFusion should have some way of getting this information easily.  My suggestion would be to add a HTTP_ADDR variable to the CGI scope that will always return the server’s ip address.

I get nauseous every time I see this question asked. I wholly believe this question exists only to start infighting amongst the development community and attract the numerous comments to the post that is assured. All the while, the poster sits back with lotion and Kelnex and smiles while the chaos unfolds around them.

I come to classify the commentors to these posts into 3 categories:

First and foremost, you have the OO purists. These are the people that use OO to the extreme. DAO, BO, IOC and any other acronym you can throw out there, they’re using it and loving it. The more abstraction and configuration, the better. They will claim that it makes developing applications faster and easy to maintain and cut down anyone that saids otherwise. If they had it there way, they would have 30 different classes per business object each containing one method. Their mortal enemy is anyone still believing and writing procedural programs.

Our next category and mortal enemy of everything OO; is the procedural programmer. They’re the ones still hanging on to the days when cfincludes and custom tags flourished in applications. Who needs CFCs when a group of functions inside a cfinclude will do just fine. Don’t tell them about design patterns or code organization, they know it all too well. If they could, they would go back in time and kill the person that mentioned cfcomponent in that one board meeting. To them OO is evil and so are the people using it.

The final category is the one that I fall into: the who gives a shit and flying fuck category. Program the way you want to program and quit telling us that we’re doing it right or wrong. We don’t want nor care how you program or the philosophy that you follow. To us, both of the other two categories need to just shut the fuck up altogether.

For a while now I’ve been looking into Ruby on Rails (RoR) to replace ColdFusion (CF) as my primary programming language of choice. There are so many things about the framework that just dazzle me to death. I know I’m comparing a language to a framework here, but to be honest, to most people there really isn’t a difference. Plus the fact that I really haven’t found a CF framework out there that I really like nor one as feature rich as RoR.

For one, I like the idea of convention or configuration (COC). How many times have you taken over an app from someone where you’ve spent days on end trying to figure out what the hell they were doing? If you embrace COC then every app is structured the same so there is no guessing at all. I can also see how COC can speed up development amongst a group of developers since everyone has to follow the same directions.

ActiveRecord (AR) is just sexy beyond belief. I love SQL, don’t get me wrong, but I grow tired of writing the same queries day in and day out (This is why I created ICEGen). Furthermore, I’ve seen some of the SQL that others have written and makes me want to throw up. If AR can help me not write the same boring SQL while preventing others from just writing it altogether, I’m sold. Coupled with the fact that the built in validation methods are just so simple to use, why would you need further convincing?

Plugins and Gems just work. I’ve seen frameworks in ColdFusion claim that you could write or download a plugin, install it and it would just work; yeah, well it doesn’t. Half the time I’m hunting and configuring files all over the place only to expense my efforts in vain. With RoR, just a simple command line and within seconds the plugin and gem are installed and work beautifully. Sure sometimes there is a little configuration to do with them, but at least in the end the plugin works as expected.

I don’t do tests, I just don’t. I’ve tried using CFCUnit and failed since it warped my fragile little mind. Tests in Rails are dead simple. Because of this, you can’t even submit a patch to the RoR team unless you include your tests. This is all done thanks to fixtures.

Those are a few things that I just love about RoR, now let’s see what huge things it’s missing that CF has.

CFDOCUMENT - What CF developer today hasn’t used this tag. There is something just magical about wrapping the tag around your invoice written in HTML and having it pull up a PDF or Flashpaper file in the browser. No need for them to have Acrobat installed so they have to print the page to PDF, it does it all for them and it’s dead simple to use. RoR doesn’t have this. PDF::Writer sucks balls and it’s hard to use. HTMLDOC doesn’t support CSS so it’s impossible to get the page to look good. Plus Flashpaper it’s even an option.

CFIMAGE - Yeah I know we just got this tag, but before you could just download imagecfc which worked just as good in my opinion and you had your image manipulation. RoR has support for ImageMagick which, if you’ve ever used it, is a dog. It’s slow as hell and doesn’t scale worth a shit. I still to this day can’t believe that this library is the defacto amongst the open source world.

As you can see there really isn’t a lot that CF offers that RoR doesn’t already have. Hopefully the RoR team will see these shortcoming and create some plugins that address them soon. For now I’m still learning and loving RoR.

I was browsing around on Reddit today and came across an article that particular struck my interest: To Use Or Not To Use Stored Procedures?

What intrigued me was that I have been a proponent of stored procedures in the past and now avoid them like the plague. I think the switch came when I started to realize how difficult and time consuming it was to write and maintain a project using stored procedures versus a project that just use parametrized queries. I also remember how difficult it was to write dynamic sql statements within a stored procedure.

I think really the only reason I used them in the past was because CF at the time didn’t support cfqueryparam and it as the only way to protect yourself against SQL injections. Once cfqueryparam came onto the seen, it took awhile for me to adopt it in my code and actually realized the benefits. Now I could write my SQL statements within CF and still have the security of a stored procedure protecting me against SQL injections. It was a blissful time; I could really pound out projects and code and debugging an application became a snap.

There were a few still out there that still voiced the myth that using stored procedures gave you a speed boost over
parameterized queries. Those people were soon put to rest when most RDMS and ODBC drivers made it so that using either way gave you the speed benefits of caching the query plan. Now this point is mute.

Today, I silently laugh at people that still think that using stored procedures in projects as the main way to communicate with their database. By creating views, using cfqueryparam and knowing the proper ways of using the different joins available; I can mimic almost any behavior a stored procedure can do when it comes to pulling data from a database.

To me I see the stored procedure in CF going the way of CFX tags… away.