RESTful Services versus SOAP or XML-RPC

February 15, 2009

The purpose of this blog posting is a quick review, for myself, on the differences and the advantages and disadvantages of RESTful services versus SOAP or XML-RPC. When is it appropriate to be using RESTful services? When is it appropriate to use SOAP? Well, if you are consuming web services, the answer is pretty simple: Use whichever is appropriate for the service being published. You don’t really have much of a choice in that situation.
The next two circumstances deserve a little more attention. First, when you are both producer and consumer of the webservice, and second, when you are the producer of the webservice for one or more outside entities, possibly the public. Now, which do you use? Well, here’s the basic rundown on each, for comparison’s sake.

REST (REpresentational State Transfer) – ie. the object is represented by the URL

1) On the plus side, it is SIMPLE, and so requires less handholding for outside entities to make use of it, and it does not require any special tools.
2) It is lightweight, so less code is required, typically, and smaller data transfers (less XML overhead)
3) The results are human readable, in most cases.
-) On the downside, it is not supported by Apache Axis 1.4, which is the version used in ColdFusion 7.

SOAP (Simple Object Access Protocol) or XML-RPC (Remote Procedure Calls):
1) It can be simple, if you have the right tools.
2) It is strongly typed and explicit, essentially establishing a contract between the client code and the service provider.

The REST approach was embraced by David H. and is highlighted in his keynotes on Ruby on Rails. The virtues of REST are touted by Dave Thomas, the Pragmatic Programmer, and others. It tends to be the favored approach for developers in Ruby on Rails, PHP, and a signature prescription for a Web 2.0 style web application.

SOAP is more “old school”, and tends to be the favored approach by Java developers.

A new driver for the SOAP versus REST pro-con discussion is the widespread emergence of mobile phones with internet capability. The assumptions about connections and bandwidth usually assigned to desktop computers do not necessarily apply to mobile phones. So, the lower overhead of a RESTful approach does contribute to the argument for using REST rather than SOAP.

Both sides have good arguments behind their use. In general, though, the trend is moving away from SOAP and XML-RPC toward the more RESTful approach, largely due to the successes it has brought sites that use REST. In an culture where there is a strong sentiment toward SOAP, likely the case in an old Java shop, it may not be the battle that you wish to engage in.


Maintaining a Windows XP System

February 6, 2009

This is low level general purpose stuff, which may be off-topic, but hopefully will prove useful to somebody. I have had to re-locate these sites a couple of times, so at least, they remain here as a reference for me.
My adventures began with the purchase of a notebook computer with SATA drives about a year ago. The first thing to note is that the notebook shipped with Windows Vista. I requested Windows XP Professional, because, at the time, ColdFusion was not supported on a Vista system. It was going to cost me extra to get Windows XP, I was told. And, indeed, as I searched on other sites selling systems, they included the option to “downgrade” to XP Professional from Windows Vista. This was just one indicator that Windows Vista was a horrible mistake on Microsoft’s part, something that they would not soon live down. Indeed, a year or so later, on the Dell site, they are offering the option to “downgrade” to XP Pro from the pre-installed Vista OS. It is not special order. It is a checkbox on the order, more than a year after the release of the Vista OS.

clipped from Ad on Dell Site Feb 6, 2009

clipped from Ad on Dell Site Feb 6, 2009


Not that XP is perfect. I wouldn’t be making a point of capturing these links (scroll to the end, they are there, I am sure), if it weren’t for one glaring oddity of the Windows XP installation procedure. The Windows XP standard installation disc (Service Pack 2), does not include support for SATA drive controllers. That’s okay, there is a way to add drivers during install, if there are mass storage drivers which are needed. The Windows XP installer will prompt you to insert the floppy disc containing the drivers into your floppy drive. Fantastic. My notebook doesn’t have a floppy drive. Most notebooks nowdays don’t come with a floppy drive. Well, I thought, no problem, I’ll just put the drivers on a USB drive, or burn them on a CD. The installation is reading off a CD, so it must be able to read from a CD, right??? Wrong. The only way to supply it with drivers mid-install, is via a floppy drive.
The only remaining solution is to add the drivers to the Windows XP installer *before* the install begins. Which means hacking the installer, somehow, or hoping some clever PC techno-whiz has pre-hacked it, and left some nice notes or better yet, some utilities to help with the process… Well, much to my pleasant surprise, the wizards of the world had been hard at work and had done that and more.
First, there is the BART PE site to create a bootable windows CD, or USB stick,
then, using that work is the Ultimate Boot CD for Windows(tm). a bootable Windows CD with a collection of utilities.
Each of these detail the process of Slipstreaming the drivers (and service packs) into the windows install, and provide utilities to assist with the task.
Going beyond the service packs, and including the hotfixes and some custom registry tweaks is Ryans VM.
For a fairly comprehensive set of drivers included in the install package, the driverpacks site is a great resource, and includes a utility to build an installer with (very likely) all the drivers you require.
And finally, for a great reference, the Windows Unattended Install (not unintended install) site is a great source of information.

Really, I hope to not need to refer back to this… but I am sure I will.


Naming Conventions for Data Objects

January 25, 2009

One of the things that was at once striking to me about David H’s description of the Ruby on Rails recipe, in the book Agile Development with Rails, was his headfirst launch into the data object naming conventions. They were as follows (this is not complete. For a more complete list, see : http://rails.raaum.org/database-conventions.html ) :

1) Database table names are always to be plural – This reminds me of a project a number of years ago, when the database was being reorganized. Well, they had decided to name everything in the singular. Their thinking was, it is obvious that a table named USER would contain users, a table named ORDER would contain orders, and a table named LANGUAGE would contain languages. It was soon discovered, however, that all of these were reserved words in the RDBMS system we were switching to. The solution was to add a character at the end of the name. So, ORDER became ORDERR and USER became USERR, and so on. The simplicity of just using plural for the table names struck me as something to lean towards in most RDBMS environments.

2) Primary Identity Fields will be named id. I’ve seen many cases where the identity field is named like a foreign key would be. That has advantages, like when the field names are matched exactly, as some tools will do. But  there is nothing wrong with just “id” for the field name, and it is clear what this means.

3) Foreign Key fields will be named (singular table name ) + “_” + “id”

At a certain point, it becomes clear that the rules are in place to assist automatic generation of various pieces of the Rails framework. By simplifying the components and requiring them to adhere to strict naming rules, the framework is able to maximize its power while minimizing complexity. The human user of the framework is admonished to conform to strict guidelines, to enjoy the large benefit.

  These “strict guidelines” (there’s an oxymoron for you), are in support of the concept of favoring “convention over configuration.”  By clearly stating the assumptions and defaults of the underlying framework, the designers have eliminated the need for configuration files which would spell out the exact same details.  Most software development teams would opt to leave the defaults in the first place, making all of the configuration work basically wasted effort.  By adopting convention, and eliminating a large chunk of configuration time, a real quantifiable savings can be immediately realized.

Often, I am lamenting the lost opportunities in computing systems, for real accommodation of the user. I find myself in situations where I have to repeat my phone number to computer systems on the phone, when a network of connected systems should “remember” my phone number, and even pass it on to the agent at the destination of my call. All of that made even more laughable given the fact that we do not block caller id, so the called party has access to my phone number by default, and should not have to ask for it in the first place.  It should simply ask if the number I am calling from is the number associated with the account.

  I was installing a printer on my computer, and operating systems said it recognized a Networked HP 2610 and asked if I would like to use it. I said yes, or clicked yes, as the case may be. Then, on the next screen, I was asked to select a driver. And not just from HP drivers, but from a large assortment of possibilities. HP wasn’t even the default.

So, it leads me to think that perhaps, as I have seen before, there was simply not enough time to address all the issues at the end of the line. The software had to be shipped and besides, we have “online updates” now anyway, so it doesn’t have to be 100%. The engineers probably wanted to take care of these last details, but were pulled off onto another project, and a new team was brought in for support and post release development. Did they plan for this from the beginning? The project managers, I mean. Or did time escape them, as it does so many of us?

Is it possible that they spent a lot of time at the beginning of the project, trying to sort out naming conventions for their data objects, or untangling legacy integrations?  Or editing configuration files for frameworks?  Or, automating things a little bit, by generating the configuration files?  (Even with automation, these things take time to do).  Is it possible that the manager, not being able to read code, did not understand the significance of the efforts under the hood, and was anxious for results he/she could “see”, and cut these efforts short?  Is it possible that with some of the up front efforts out of the way, the underlying engine of the project basically together, that the focus could be returned to the customer, and better managing workflow related tasks?

I, for one, would join the chorus of those who point out the significance of the approach used by David H. in the Rails framework, rather than the specific language he utilized.  That said, isn’t the language itself a convention, and the act of using a different language, a sort of configuration?  Food for thought.


ColdFusion Unit Testing Frameworks

April 19, 2008

I am starting from scratch, putting in a unit testing framework, and working within the existing organization’s culture to introduce enough of the tool’s benefits without burdening the organization with too many of the downsides. Everything has a downside, a cost, or whatever you wish to call it. There is no free lunch.
The first steps were to gage the organization’s desire for the possible benefits of a unit testing framework, and their willingness to commit to moving forward, and accepting the cost. Having been in an “extreme” programming environment, which was only “extreme” in the sense that projects were “extremely” haphazard and “extremely” mismanaged, making sure that people are clear on what can be expected from implementing some test automation for unit testing and regression testing. Automated does not mean that you do nothing, and the machine does everything. It is difficult to know what people have been sold by the trade journals, and blogs, and common terms are often misappropriated.
The current environment is Flex/Actionscript and HTML, with a ColdFusion backend, with a ColdSpring framework. The goals are:
1) Automated testing with Ant, with performance metrics logged in a database, and pass/fail results e-mailed nightly to interested parties. (Thorough regression testing and reporting is key).
2) Eclipse Integration or reasonably nice Unit Runner, with easy ability to select individual tests, or test suites. (Easy sell to the engineers is key)
3) Mock Objects, automated test generation, anything to minimize the time impact on engineering, while maximizing the benefit, and keeping the program moving.

Sean Corfield had mentioned MXUnit fairly recently, so it seemed worth a look. Given the higher volume of activity on MXUnit, when compared to CFCUnit and CFUnit, it seemed like a reasonable way to go, for the best of all worlds for future itegrated add-ons. The first downside I will mention is that *MXUnit‘s Eclipse Integration is Not Flex Builder 2.01 Compatible, or rather, not compatible with the version of Eclipse (3.11) that ships with Flex Builder 2.01*  This wasn’t super clear from the  MXUnit website, so it’s possible for an engineer to go through the installation instructions, and end up with a failing plug in.  This might not be a problem for some organizations, but may be for others.  Most of the team has not yet upgraded to FB 3, so it could be an issue at the moment.

  MXUnit’s Eclipse integration isn’t quite finished, or at least that’s how it felt for me.  It “worked”, but was lacking a few things that I thought were important.  An html or Flex based unit runner will do the trick though, so it’s not a huge problem.  The things which make the integrated unit runner a little less than usable, for me, are: 1) It seems to have no memory of past tests, so I would have to go through the selection process for the unit test every time; some way to save the available test cases/test suites would be desireable/required, 2) The test case selection process was awkward; I found myself unable to select a Test Case which I knew was present on more than one occasion;  This could be forgiven more easily, if it would remember the test cases I had selected in the past, but I was required to select/find the test case with each restart of Eclipse, or any time I wanted to switch tests

On the plus side, the ant unit runner does a great job, and it is clear how to modify the ant task.  The availability of the different test result formats, allows me to feed the results into a variety of destinations with ease.  The key item was logging test results and performance metrics, and not just logging into a text file, but logging into a database table, so it could be consulted for history.  I was able to hack this item in really easily using the cfquery output format for the testResults.

I should at least mention that CFUnit and CFCUnit are both seemingly capable frameworks.  I was able to set up integrated Eclipse (with Flex Builder 2.01!) unit tests, and test suites.  But the availability of the test Result Formats, and the volume of project activity, were enough to convince me.  That does not mean that I am right, nor does it mean it is the best choice for everyone.  But the software selection is but one small piece of the puzzlement.

ColdFusion Unit Testing Frameworks, and related info:

Next steps, automating test generation, designing effective unit tests, and Flex Unit testing frameworks.  I’ll post if anything interesting comes up.

 


Flash Creations – a quick catalog

April 19, 2008

With no clear category to post these in, but wanting to share with those who may visit, and bookmark for a reminder to myself, here are “galleries” of beautiful, and instructive, actionscript creations.  Most of these are provided along with source code.  A bestiary, gallery, or compendium, call it what you will.  (And some of these talk back, if your sound is turned on):

http://www.liquidjourney.com/flash/lq3.html

http://krazydad.com/bestiary/

http://www.robertpenner.com/index2.html

http://www.indivision.net/genomesea/

http://www.arseiam.com/index2.htm

http://www.generatorx.no/

http://www.levitated.net/daily/index.html


ColdFusion 8 ValueObjects vs Typed Structs for Flex RemoteObjects

March 28, 2008

ColdFusion Objects transfer nicely over to Flex, making the remote data connection for Flex run like a dream.  It can get out of hand, however, when there are a large number of Objects to return from ColdFusion, for example, an array of ValueObjects, which might have other value objects as members.  In researching this, I ran across a few very helpful postings.  Basically, CF8 has a workaround wherein you use typed Structs instead of full blown Objects to pass VO’s to Flex:

http://www.briankotek.com/blog/index.cfm/2008/1/28/Returning-Typed-Structs-vs-CFCs-to-Flex

http://groups.google.com/group/transfer-dev/browse_thread/thread/0abdb2191dcfd226#2cbf827754e75376


So, I decided to run a few very simple tests to see what the impact of CreateObject was on a large dataset.  I put together a CF script with a loop to create 5000 objects using CreateObject (with init), another for 5000 with CreateObject (without init), another to simply duplicate a template Object and another to create 5000 structs.  The breakdown and the code follow:
 

Test

Iterations Elapsed Time (ms) ms/Instance
structTest 5000 157 0.0314
FullCreateTest 5000 17468 3.4936
createTest 5000 16610 3.322
dupeTest 5000 12469 2.4938
structTest 5000 15 0.003


This was run on a CF8 Box with JRun running on Java 1.5 I had similar results on a CFMX 7 Box with JRun running on Java 1.42 The option of rolling query results into typed structs is really a lifesaver given the performance numbers.       

<cfset t1 = GetTickCount() />

<cfset myArray=ArrayNew(1)>
<cfloop from=”1″ to=”5000″ index=”i”>
<cfset newStruct=StructNew()>
<cfset newStruct["iter"] = #i# />
<cfset ArrayAppend(myArray,newStruct) />
</cfloop>
<cfset t2 = GetTickCount() />
<cfset elapse1 = t2 – t1 />
<cfset myArray2=ArrayNew(1)>

<cfloop from=”1″ to=”5000″ index=”i”>
<cfset newObj=CreateObject(“component”,”com.test.TestIter”) />
<cfset newObj["iter"] = #i# />
<cfset ArrayAppend(myArray2,newObj) />
</cfloop>
<cfset t3 = GetTickCount() />
<cfset elapse2 = t3 – t2 />
<cfset myArray3=ArrayNew(1)>

<cfloop from=”1″ to=”5000″ index=”i”>
<cfset newObj2=CreateObject(“component”,”com.test.TestIter”).init() />
<cfset newObj2["iter"] = #i# />
<cfset ArrayAppend(myArray3,newObj2) />
</cfloop>
<cfset t4 = GetTickCount() />
<cfset elapse3 = t4 – t3 />
<cfoutput>Results<br/>Structs : #elapse1# ms for 5000</br>

CreateObject (no init) #elapse2# ms for 5000<br/>CreateObject (with init) #elapse3# ms for 5000<br/></cfoutput>

<cfcomponent name="TestIter"> 
      <cfproperty name="iter" type="numeric"> 
      <cffunction name="init"> 
            <cfreturn this /> 
      </cffunction> 
</cfcomponent>

CFSCRIPT – The little language that …

November 18, 2007

To quote Ben Forta in 2004: “<CFSCRIPT> today is in a strange place. ” (http://www.forta.com/blog/index.cfm?mode=e&entry=1416) I don’t think much has changed in that regard. The fact is, Macromedia ColdFusion stopped partway through the metamorphosis of becoming a scripting language. Kind of like stopping part way through a sex change; the important parts are there, sometimes both sets, and it can be ugly to watch. Now it’s in Adobe’s care, and there are more than just PHP and ASP wandering by and looking at CFSCRIPT, with a mild sense of relief (glad that’s not me) and perhaps a bit of Schadenfreude.

I’ve read articles about Coldfusion programmers jumping ship and running to Ruby on Rails, I wish everyone the best voyage possible, whichever boat they sail. I spent years coding C++ as a plugin to Netscape, to serve up web pages. Then Apache Server. Coldfusion looked like a treat from that vantage point. Despite it’s imperfections, it is a powerful way to make many web applications happen very quickly. That doesn’t change the fact that CFSCRIPT could never run on it’s own. It’s incomplete. Like Pinnoccio, always needing Gepetto around to keep working on him, and no Blue Fairie coming to turn him into a real boy. Yes, CFSCRIPT is in a strange place, and it will likely see out its days in the place that it is.

There is an almost audible sigh of relief that escapes when entering a block of logic which won’t be needing html tags or CFML to make it do it’s job. But eventually the lines of code free of the greater than and less than signs is brought to a screeching halt by one of those things that cfscript just cannot do properly, or requires the esoteric approaches of the guru to get through.

I noticed Sean Corfield’s scripting plugin post, basically allowing a Coldfusion 8 developer to plop in some PHP here, some Ruby there. (a moody person could write alternative verses of PHP and Lua, bringing a Wagnerian feeling to the code). A colleague has been telling me about Groovy, and its possibilities and I stand intrigued. Something will have to yield, one way or another. For things CF could not handle, I used to opt to extend CF with C++ CFX tags. Now, with CF being Java based, it is cleaner to extend with Java (my opinion). Can Groovy solve some problems that CFSCRIPT could not? Is it compelling enough to justify a significant effort in that direction? Groovy and Hibernate play well together (supposedly). I may do a little with Groovy’s Gant (to get past the Ant XML build structure), but beyond that I don’t know. Groovy is too new for risking on my customers, for the time being. But what the future holds, I cannot tell.

As for the rest, I am grateful for having had the chance to work with all of the languages I have. I wish every programmer could have a wide exposure to languages in that way. I feel the same way about natural languages (written and spoken and signed-eg. American Sign Language). The more one can learn about other languages, and their inherent approaches to solving problems, and their implications, the better one can understand and utilize their home language. And though I make fun of different computer languages, I enjoy working with them a great deal.

After doing some work with Lex/Yacc for preprocessing of some code, I did some experimentation with the problem of carrying the cfscript language the distance, by adding “real” classes, to replace the tag based cfcomponent artifact.    Then, adding to that some special system classes that could yield database connectivity and scaffolded views, and cfscript is more complete, operationally.  None of this changes the fact that  CF is locked behind a webserver, and there is no past nor any future for CF based console apps or desktop apps.  It is a backend database application server for the web, when it is doing what it does best.

It is difficult *not* to conclude that Adobe (and perhaps Macromedia) purposefully prevented the completion of the ColdFusion CFSCRIPT “language”.  And given that, it would be interesting to understand exactly why, though one could guess that they don’t want to be a big player in that marketspace, to distract their focus from other more interesting areas.  For the developer who continues to hitch his career on ColdFusion, I would admonish them to add a few additional tools into their toolboxes.


Follow

Get every new post delivered to your Inbox.