Blog

Entries Tagged as Web Development

CFHTTP equivalent in Java. Really, Java, Really?

November 03, 2009 · 3 Comment s

I was talking to my boss Kevin, and we were talking about how concise ColdFusion makes certain rote tasks, and he mentioned trying to duplicate CFHTTP in Java. He talked about how it went on for line after line, after line. I figured he was talking about something in the order of magnitude of about 2 or 3 times as much code.

He forwarded me a post on making HTTP GET and POST requests in Java. As the post shows it takes 12 lines of code just to import all of the classes you need. When you're all said and done it takes about 30 or so lines of code to actually make a GET request. So it takes about 42 lines of Java code to duplicate the functionally that can be called in 1 line of ColdFusion using CFHTTP. I never noticed it was that big a difference. All that versus:

<cfhttp url="http://example.com" />

 

Now, I'm sure there are easier ways of doing this. And after you build the class and method once, you can just reuse the object repeatedly. But in this day and age of SOA, SOAP, and REST, that seems like something that should be built into the language.

I'm not trying to make this a bash Java post. Really I'm not. Java can do lots of things ColdFusion cannot. In fact Java networking is this verbose because it has more options; it can do low level socket communication. I know, when I've needed it in ColdFusion, I've dropped down to Java to write it.

But as developers, I think there are lots of places where we don't add value, but are still forced to work:

  • Getting reporting data out of a database? You add value by writing good complex SQL, but not by writing the database connection code.
  • In basic database applications, you add value by designing the database, but not by writing CRUD code.
  • In a REST and SOAP world, you add value by mashing up services people have thought of combining, not by making the HTTP call to get the data.

I know frameworks, libraries, code reuse, and other encapsulation techniques are ways around this.

ColdFusion as an abstraction layer on top of Java is another way. It's the way I do it. And because I do it that way, I never have to write more code then I have to for an HTTP GET request, or email, or database connection, or .NET integration, or Exchange call, or Spreadsheet creation, or …

 

3 Comment s Tags: Java · Web Development · ColdFusion

How to Get Started Developing in ColdFusion

February 09, 2009 · 8 Comment s

I've seen a couple of tweets around this, and instead of trying to answer every one in 140 characters, I'm instead going to point people to this article.

Get the Developer's Version of ColdFusion

The developer's version of ColdFusion is free. It's not a trial version; it is just free, but with a few restrictions. It is limited in the number of IP addresses it will answer to, and certain featured like cfdocument and cfchart get watermarks placed in their generated content. If you purchase a licensed copy, this version can be upgraded without a reinstall.

In addition to the Developer's Version a Full trial version is available. It is not limited in ability, but will only run for only 30 days. If you purchase a licensed copy, this version can also be upgraded without a reinstall.

Download the free developer's version or trial version of ColdFusion

Also I will point out that if you are a member of the Faculty, Student Body, or Staff at a Higher Education institution using ColdFusion for academic purposes, then you are eligible for a free license.

Apply for a free license of ColdFusion for Education.

Pick an Editor/IDE

There are a few options to choose from for editing ColdFusion. Obviously any text editor will work, but there are a few choices if you are looking for an editor with language support for ColdFusion.

Dreamweaver has color coding, language reference and RDS integration with ColdFusion. It is an especially attractive option if you are coming from another web technology and already working with it. If not you can also try it out its demo version.

Download the trial version of Dreamweaver

CFEclipse is a pretty full featured editor for ColdFusion. It is an especially attractive option if you are working with Eclipse already as a Java developer, or using Flex Builder.

Getting started with CFEclipse

Finally, although it is not available today, the Adobe project currently named "Bolt" is a ColdFusion IDE. I'd bet on it becoming the standard tool for ColdFusion development when it comes out.

Learn more about Bolt

Learn about ColdFusion

Pretty much everyone will point you to the Adobe ColdFusion Web Application Construction Kit, Volumes 1, 2, and 3. Combined they are pretty daunting, but you are just getting started, so buy volume 1 for now. Disclaimer: the first author of the book is Ben Forta, for whom I work. I would still recommend it even if I didn't.

Get the book at Amazon

Also available is community member John Farrar's book ColdFusion 8 Developer Tutorial. I haven't read it, but check it out and see if it is more your style.

Get the book at Amazon

In addition to the book route, there is a ton of information available on the Adobe Developer Center. The include simple how to's and higher level articles like theory behind high availability.

Connect with Other ColdFusion Developers

There are several ways to tap into the ColdFusion Community. Here are just a few:

Also deserving special mention is ColdFusionBloggers.org. This site was setup by Ray Camden, and is a ColdFusion only blog aggregator. Ray's pretty aggressive about policing the list (and publicizing the site ;) ) so in many ways it's a better resource than AXNA.

ColdFusionBloggers.org

Get Open Source ColdFusion Code

A few years back Ray Camden started RIAForge as a place to store Open Source applications written for ColdFusion and Flex. Currently it has over 600 projects. Check it out before you try and reinvent the wheel.

RIAForge open source code for Adobe technologies

Online Video Presentations

There are a few collections of ColdFusion audio and video presentations by some of the best voices in the community.

I'll add more to this as I find new ones, or people point out to me which obvious ones I've forgotten or not explained enough.

8 Comment s Tags: Web Development · ColdFusion · Higher Ed

Name This Product

February 01, 2009 · 4 Comment s

I'm going to do a little exercise. I am going to describe a product. Tell me what technology product I am talking about:

  • Niche product
  • Users are often derided for using it.
  • Outside pronouncements of its obsolescence are common
  • Users are passionate often to the point of zealotry.
  • Users claim to be much more productive because of it.
  • It holds a minority market-share.
  • It's commonly criticized for costing more than the competition

So... What am I talking about?

Apple, what product did you think I was talking about?

I guess I'm trying to point out, that I've been thinking a lot about a particular product's place in the collective common wisdom, and perhaps we need to change it. But before we change it externally, we need to make sure internally in the community, we know what we offer.

4 Comment s Tags: Web Development · ColdFusion

Stop Looking for ColdFusion Developers

January 27, 2009 · 14 Comment s

One of the biggest complains I hear from management types about ColdFusion is that they can't hire good ColdFusion developers. I think that this occurs because people often overlook one of ColdFusion most accepted benefits. ColdFusion is exceedingly easy to learn. Which leads me to my biggest piece of ColdFusion hiring advice – don't look for good ColdFusion developers, look for good web developers, if they know ColdFusion, great, if not, teach them, or let them learn it.

The argument I hear back on this point is "we don't have the time of resources to train someone; we need them to hit the ground running." I think this is penny wise pound foolish. Based on anecdotal evidence only, I would contend that it takes an average web programmer about 1 or 2 months to learn ColdFusion. (This assumes they know HTML, CSS, SQL and another server side language.) I've seen some ColdFusion job hunts take upwards of 9 months. You can't afford the month to train an employee, but you can be without them for 9 months? That doesn't make a lot of sense to me.

Add to it that for the cost of 1 or 2 months, you get a ColdFusion developer who knows another language. Developers who know more languages tend to be better. ColdFusion programmers that know Ruby for example are usually better Object Oriented ColdFusion developers through the knowledge they picked up in Ruby.

Now, I'm not arguing that you shouldn't hire a ColdFusion developer if you can find one. I happen to know a few that are looking for work. I also don't mean to suggest that finding a good web developer is necessarily that much easier than finding a good ColdFusion developer. Finding "good" people is never easy, but I am arguing that you need to increase your chances of finding someone to fill your position. You can do this by opening up your search criteria, and letting one of the major selling points of ColdFusion actually work for you.

What do you think, does this agree with what you've seen in the job market of late?

14 Comment s Tags: Web Development · ColdFusion

Digest Authentication in ColdFusion

January 08, 2009 · 12 Comment s

I'm working with the ConstantContact API webservice, and ran into a slight problem. The API uses Digest Authentication, and ColdFusion does not support Digest Authentication in cfhttp. I found this out by reading in the live docs that:

The cfhttp tag does not support NTLM or Digest Authentication.

The ConstantContact forums pointed me to a custom tag cfx_http5. But I hate CFX tags. I like to place as few dependencies on the ColdFusion Administrator as possible when I code. CFX tags also tend not to make the trip the first time in server migrations or emergency moves. It might be my own prejudice but, no, there will be no custom tags.

Which leaves me to implementing some Java client, as luck would have it there was ample documentation on doing this. I just needed to use the open source Apache HTTP client. To work with them, I had to add them to the class path, or add an entry in the ColdFusion Administrator class path list. That would have bought me nothing, as I didn't want to go through the administrator.

This left me looking for a way to dynamically call jar files. If only there was some way to dynamically call jar files in ColdFusion... preferably written by someone with a marsupial pouch.... Ohh wait, Mark Mandel wrote the Open Source project JavaLoader, which allows just that. Hmm, and Mark is a mammal from Australia. Things are looking good.

So I was able to build my http client with Digest Authentication. I added some code that formatted the response like a cfhttp struct, so that if there were other advantages to this method I could just swap out this for cfhttp in a pinch. The code is below in the extended section of this blog post.

I was trying to do 3 things with this post:

  1. Explain how to use Digest Authentication with ColdFusion
  2. Show how with ColdFusion Open Source community and ColdFusion's ability to call Java, there isn't much you can't do with it.
  3. Further the rumor that Mark Mandel is a marsupial.

I hope I've done these three things for you.

<cfcomponent>
   
   <cffunction name="init" output="FALSE" access="public" returntype="any" hint="Psuedo constructor that allows us to play our object games." >
      
      <cfscript>
         var paths = arrayNew(1);
         var rootPath = GetDirectoryFromPath(GetCurrentTemplatePath());

         paths[1] = rootPath & "/jars/commons-httpclient-3.1.jar";
         paths[2] = rootPath & "/jars/commons-codec-1.3.jar";
         paths[3] = rootPath & "/jars/commons-logging-1.1.1.jar";

         //create the loader
         variables.loader = createObject("component", "javaloader.JavaLoader").init(paths);
      </cfscript>
      <cfreturn This />
   </cffunction>
   
   <cffunction name="get" output="FALSE" access="public" returntype="struct" hint="Runs a get request." >
      <cfargument name="url" type="string" required="TRUE" hint="The url to call." />
      <cfargument name="username" type="string" default="" hint="The username to pass to the service." />
      <cfargument name="password" type="string" default="" hint="The password to pass to the service." />
      <cfargument name="realm" type="string" default="" hint="The realm to pass to the service." />
      <cfargument name="port" type="numeric" default="80" hint="The port to pass to the service." />
      
      <cfscript>
      
         var result = "";
         var credentials = loader.create("org.apache.commons.httpclient.UsernamePasswordCredentials");
         var HttpClient = loader.create("org.apache.commons.httpclient.HttpClient").init();
         var httpGet = loader.create("org.apache.commons.httpclient.methods.GetMethod");
         var AuthScope = loader.create("org.apache.commons.httpclient.auth.AuthScope");
         var jURL = createObject("java", "java.net.URL").init(arguments.url);
         
         if (len(arguments.username) and len(arguments.password) gt 0){
            AuthScope.init(jURL.getHost(), arguments.port, arguments.realm);
            credentials.init(arguments.Username, arguments.password);
            httpClient.getState().setCredentials(authScope, credentials);
         }
         
         httpGet.init(arguments.url);
         httpClient.executeMethod(httpGet);
         
         result = convertHttpClientResponseToCFHTTPFormat(httpGet);
         httpGet.releaseConnection();
      
         return result;
      </cfscript>
      
   </cffunction>

   <cffunction name="convertHttpClientResponseToCFHTTPFormat" output="FALSE" access="public" returntype="struct" hint="Takes the response from the HHTP client and formats like cfhttp." >
      <cfargument name="httpGet" type="any" required="TRUE" hint="The httpGet Java Object that was called." />   
   
      <cfscript>
         var result = structNew();
         var responseheader = structNew();   
         responseheader['Status_Code'] = httpGet.getStatusCode();
         responseheader['Explanation'] = httpGet.getStatusText();
         responseheader['Http_Version'] = httpGet.getEffectiveVersion().toString();
         header = httpGet.getStatusLine().toString();
         
         headers = httpGet.getResponseHeaders();
         
         for (i=1; i lte ArrayLen(headers); i=i+1){
            responseheader[getToken(headers[i], 1, ":")] = getToken(headers[i], 2, ":");
            header = listAppend(header, headers[i], " ");
         }
         
         result['Charset'] = httpGet.getResponseCharSet();
         result['ErrorDetail'] = "";
         result['Filecontent'] = httpGet.getResponseBodyAsString();
         result['Header'] = header;
         
         if (structKeyExists(responseheader, 'Content-Type')){
            result['Mimetype'] = GetToken(responseheader['Content-Type'], 1, ";");
         }
         
         result['Responseheader'] = responseheader;
         result['Statuscode'] = responseheader['Status_Code'] & " " & responseheader['Explanation'];
         
         if(   not structKeyExists(responseheader, 'Content-Type') OR
            FindNoCase("text", responseheader['Content-Type']) OR
            FindNoCase("message", responseheader['Content-Type']) OR
            FindNoCase("application/octet-stream", responseheader['Content-Type'])
         ){
            result['Text'] = "YES";
         }
         else{
            result['Text'] = "NO";
         }   
            
   
         return result;
      </cfscript>
   
   </cffunction>

</cfcomponent>

12 Comment s Tags: Web Development · ColdFusion

2009 Predictions in Higher Ed

January 01, 2009 · 1 Comment

Spurred on by Kevin Hoyt, who commented on my last post I have some predictions for technology in higher education as a whole.

First, a quick background. The economy sucks. This is good news and bad news for higher ed. Enrollment and applications will be up. Bad news, is that most institutions arenapost entirely funded by tuition. Money comes into schools from state governements and the federal government in addition to money from their endowments and donations. All of those sources will be down in the next two years at least. Also in the picture is that fact that because of institutional culture of tenure, and the compliance issues that come from taking federal money, most higher ed institutions cannot cut budgets by trimming employees from the books. Good news, you've still got your job, bad news, remember Ed who quit, you've got his too.

Cost savings will be sought elsewhere. This is going to lead to a contraction of commitments. Upgrades will be postponed. Technology investments (big virtual machine hosting hardware, SAN's) will not be pursued.

So what will all this lead to...

Hosting
Up until now, a penchant for open source technology, and educational discounts have made schools prefer to host their own services a little longer than the rest of technological community. However, that was before the financial craptaculon. External hosting will be considered for applications which would never have been outsourced before. It's already started for student email, IM, web sites, and storage. It will accelerate and be targeted for smaller burdens like staff email, intranet sites, and public websites.

Virtual Classrooms
Virtual classrooms where schools could sell an unlimited number of seats to an audience for a set cost has been a holy grail for a few years now. With cut travel budgets hitting continuing education dollars, and the rise in applications coupled with the pressure to bring in revenue, they will have no choice to squeeze every dollar they can. Expect a lot of activity here.

Development Language free for all
Because of the rise of hosting for previously unhosted solutions, there will be no lock in for particular platforms or languages. Want to try Ruby or make the switch to .NET? No worries, you don't have to build an environment, just rent it. It provides opportunities for highly productive languages and solutions to re-argue their case to the higher education world.

Students
Students are going to be looking to either stay out of the job market for as long as possible, or get trained in skills that will more likely get them hired. Any schools out there have Flex or Ajax content in their program, congrats, your students are still marketable. Expect more focus on vocational skills, like specific languages to be the rage.


1 Comment Tags: Web Development · ColdFusion · Flex · Higher Ed

2009 Predictions

December 30, 2008 · 5 Comment s

With the new year fast approaching my mind turns to what's coming up in the next year.

Centaur
Centaur is slated to be released in 2009 as ColdFusion 9. I'm confident it will be. ORM and the IDE will be the most talked about features. Although ORM is talked about, it will be slow to move in to the mainstream of CF development. Considering the time it took to get CFC's to be widely adopted, I think ORM will be what's hot in 2010 but bleeding edge in 2009.

The IDE will be a big seller, and I mean seller. I think the IDE will be a for purchase and stand-alone product. I think there will be a lot of people developing on Bolt and Centaur for production ColdFusion 8 applications for some time to come.

ColdFusion Development
Apple will continue to gain market share among CF developers. Ubuntu boxes will also proliferate as Vista users with regrets can't justify new hardware purchases but tire of Vista's drawbacks.

Web Development in General
Rails and Merb joining together will cause the Ruby development community to get a major boost. The meme that "rails is cool, but not ready for enterprise" will really get challenged.

Technology in General
There will be an increase in problems due to companies putting off equipment upgrades in an attempt to cut costs. I think companies will continue to push more hardware outsourcing regardless if they experience a cost-cutting driven failure or not.

That's all I have for now, if I think of more I'll add...


5 Comment s Tags: Web Development · ColdFusion

Formal Code Reviews vs. Automatic Tools

December 22, 2008 · 2 Comment s

One of questions I always get when talking about code reviews, formal or otherwise, is "What do you think about automatic code review software like CodeCop or varScoper?"

First off I'll say, I love and use varScoper. Second, I like the idea of CodeCop, but I've never been good enough at writing regular expressions to craft my own rules well enough to use it. Those points being said, as great as these tools are, they do not even come close to eliminating the need for formal code reviews.

Automatic testers are great at finding small discreet known issues:

  • Did you var scope every variable in ever function?
  • Did you make sure not to use relative url's in cfschedule?
  • Did you use cfqueryparam on all of your user input driven queries?

But they can't figure out bigger picture issues like:

  • Is this function named "computeCosine" actually returning the sine?
  • Is there sufficient validation occurring on form posts before they are being processed?
  • Is this function doing something that a built in function could be doing better?

In addition to the hard to compute issues above, there are the unknowns. Until someone discovered there was an issue with using relative url's in cfschedule there was no rule written in the code review tool. It takes human eyes to discover these issues, either during a review, or during bug fixing. Only after they are discovered can they be codified.

To put more succinctly and in a metaphorical manner:

Automatic code review tools are spell checkers. Formal code reviewers are editors. Spell checkers and even grammar checkers don't prevent you from writing perfectly spelled and constructed crap. You need an editor to prevent that. Just as code review tools don't prevent you from writing crap code that adheres to all of their rules.

So use automatic tools before a formal code review, just like you spell check an email before you send it out. But don't rely on an automatic tool as your last line of oversight.

 

2 Comment s Tags: code reviews · Web Development · Running a ColdFusion Shop

Another Unfuddled Experience

December 16, 2008 · 3 Comment s

We started using Unfuddle.com to be our Subversion, bug tracking, and project management solution a few months back. As time has gone on I've become to rely on it heavily. Nothing illustrates that quite as much as the feeling you get when it isn't accessible anymore.

You see my business office changed their credit card info. They gave me access to their new card and a typed its numbers into Unfuddle.com's automatic biller. When I did that, I must have transposed a few numbers. Yesterday was the day that automatic billing takes place. We were charged, the charge failed, and as such due to a bug in their system our quota was lowered to its free level (200MB) instead of our actual quota (10GB.) Once you go over quota, they lock down your account to prevent subsequent commits and updates. I'm sure they do this to prevent runaway processes from going over quota and causing problems. It also has the effect of bringing everything to a grinding halt.

I fixed the credit card, and got confirmation from the system that I had entered it correctly this time. But still no commits.

I sent in a support email, as that is their only means of support contact. But my boss started circling asking when he would be able to commit again. He started talking faster, and faster, which made it clear that he was getting agitated by the possibility of problems publishing his application for an important demo this morning.

So I started searching through previous correspondence with support to see if they had a phone number in their signature. Lo and behold, one support technician had his mobile phone in his signature. At this point I'm torn: I don't want to bother this guy on his mobile; but I didn't want my boss to become John Moschitta. Finally after looking up the area code and finding out the guy was in Hawaii, I decided that if he got to be a cool web 2.0 programmer and live in Hawaii then I was going to not feel too bad about calling him on his mobile.

He was extremely cool about being bothered (he was in fact not in the office that day). But I explained the situation, and told I would accept being shunted to another support person (as he was out of the office,) but he would have none of it and within literally 3 minutes of talking to him, we were happily unfuddling again. He also said he would look into the bug that caused us to not have the customary 2 week compliance period.

I'm already a pretty pleased customer but this turned me into a passionate customer. That's the sort of competent, fast response you wish your vendors would give every time.

In short, Unfuddle.com rocks.

3 Comment s Tags: Subversion · unfuddle · Web Development

Knowledge@Wharton Upgrades

November 11, 2008 · No Comments

Today the Knowledge@Wharton tech team put into the wild something I've been working on for some time: a new platform for Knowledge@Wharton and India Knowledge@Wharton. The new platform consists of the following:

  • Windows 2008 Load Balanced Cluster
  • Core Services Code Base and ColdFusion 8
  • Layout
  • Development and Publishing System

Windows 2008 Load Balanced Cluster

We built a two node cluster using Windows 2008 64 bit Enterprise Version. One node is a VMware instance, and one node is a blade server. I like this configuration as I only have to worry about a machine warrantee on one node, but I have the backup of a hardware-based node if something goes wrong with our VMware installation. Not that such an event is likely; I would prefer not to tempt fate.

I've mentioned it before that we don't use Load Balancing so much for load as for availability. By having dual node clusters for our production environments we buy ourselves zero downtime patch cycles. We did have a little trouble getting NLB on Windows 2008 working, but we did get it fixed after talking to Microsoft support.

The upgrade went really smoothly. I'm used to using cnames to handle this sort of move, but due to SSL considerations knowledge.wharton.upenn,edu has an A record. The easiest way to make the change was to add the new nodes to the existing Windows 2003 cluster, then remove the windows 2003 nodes. It worked like a charm, and I think it will be my new procedure as it was shockingly easy.

Core Services Code Base and ColdFusion 8

In looking to upgrade Knowledge and India Knowledge to ColdFusion 8 I had to touch a lot of the code. Not so much because there was a problem with it, but because we wanted to take advantage of new features. In the course of doing that I discovered that the main Knowledge site and India contained a lot of duplicated code between them. I was able to centralize it and then add new features to both sites. There are two main features that I added to the central code base: cached queries and search driven folksonomy.

Caching the queries was pretty trivial. I rolled my own instead of using an existing caching framework or native ColdFusion caching. I wanted an easy to flush cache system that didn't need to be too complex. Because of the highly normalized nature of the database, I couldn't get a tremendous performance boost through indexing; caching however has proven to be the correct solution by a long shot. It makes sense; we have a lot of frequently read, rarely written data here. I'm just surprised at the overall boost to the site we accomplished with one fix.

"Search driven folksonomy" is a cool idea that my boss Dave had back in 2006. It was running for awhile then got deactivated for some reason and I just re-implemented it. Basically, instead of having people manually tag articles, instead use our search referral keywords to tag articles automatically, then when an article hits some sort of critical number of hits for a keyword to an article that keyword becomes a tag on that article. We've enabled the collection piece for now and will enable tag display once we tweak the model a bit after getting some real data.

Layout

I can't take credit for the look and feel. This was done by Dave and a co-worker, Sanjay. They worked on pushing Knowledge to a more current centered layout, along with a few other tweaks to accommodate advertizing without compromising the editorial content.

The one thing I contributed here was a custom tag that converted an article to an array of <p> tags. Then the article custom tag was able to wrap around other custom tags and display them in the flow of the article at set positions in the array, or the next pre-determined location in the array, or at the end. It made for a very flexible way to showcase link suggestion or article tools within the flow of the article thereby freeing up space for the aforementioned ads.

Development and Publishing System

This was the hardest to tackle part of the whole thing. Because I was asking people to change the way they worked. But Dave and Sanjay were open to it, especially since I promised that it would make their lives much easier after a little bit of pain.

The old model consisted of doing development on a shared development server with no source control. Changes were manually pushed to production. Occasional copies were made of the code. Communication about changes were ad-hoc and not necessarily as frequent as the changes.

The new model pushes development to local installs of ColdFusion. Source control is handled through Subversion hosted on Unfuddle.com. Communication about changes occurs on every update, thanks to Unfuddle's notification system. The shared development server gets automatically updated from the trunk on every svn commit via svn commit hooks. Then to move the code around I have one click ANT tasks that handle updating development from Subversion, updating staging from development, updating production from stage, and a unified task that can does all of the updating in sequence (subversion to dev to stage to production in one click with a warning that you should only do this if you are sure about it.) All of this is to accommodate all of the various publishing needs we have. I then wrote ColdFusion that calls the ANT tasks, and an AIR application that calls the ColdFusion. This gives us a one-click publishing tool that we can run from a browser or a desktop application.

We replaced one node of the cluster yesterday, fixed a few bugs, then replaced the other node today - all in all, a very smooth upgrade. I'm extremely happy. It's a lot to accomplish in 3 months. Mostly, after years of working on very backend systems which never get touched by users, it's extremely gratifying to work on something that I can show off.

No Comments Tags: unfuddle · Web Development · ColdFusion