My Secret Life as a Spaghetti Coder
home | about | contact | privacy statement | getting started with cfrails
Something's been bothering me lately. It's nothing, really. ?, ?, null, nil, or whatever you want to call it. I think we've got it backwards in many cases. Many languages like to throw errors when you try to use nothing as if it were something else - even if it's nothing fancy.

I think a better default behavior would be to do nothing - at most log an error somewhere, or allow us a setting - just stop acting as if the world came to an end because I *gasp* tried to use null as if it were a normal value.

In fact, just because it's nothing, doesn't mean it can't be something. It is something - a concept at the minimum. And there's nothing stopping us from having an object that represents the concept of nothing. More...

Hey! Why don't you make your life easier and subscribe to the full post or short blurb RSS feed? I'm so confident you'll love my smelly pasta plate wisdom that I'm offering a no-strings-attached, lifetime money back guarantee!



When I try out a product, I like it to work. Sometimes, I like to tinker with things to gain a better understanding of how they work. Occasionally, I can manipulate them with skill. At other times, I'm tinkering in the true sense of the word.

I'm going to point out a few problems I've had with some products I've been using. I won't name names, but some of you who also use these products (or similar ones with the same problems) might understand what I'm talking about. Hopefully, you all can draw a good conclusion from it.

I'm not a mechanic, but sometimes I might want to look into my radiator. Is there a reason I need to disassemble the front of my car to unscrew the radiator cap? More...


This is a story about my journey as a programmer, the major highs and lows I've had along the way, and how this post came to be. It's not about how ecstasy made me a better programmer, so I apologize if that's why you came.

In any case, we'll start at the end, jump to the beginning, and move along back to today. It's long, but I hope the read is as rewarding as the write.

A while back, Reg Braithwaite challenged programing bloggers with three posts he'd love to read (and one that he wouldn't). I loved the idea so much that I've been thinking about all my experiences as a programmer off and on for the last several months, trying to find the links between what I learned from certain languages that made me a better programmer in others, and how they made me better overall. That's how this post came to be. More...


Since the gift buying season is officially upon us, I thought I'd pitch in to the rampant consumerism and list some of the toys I've had a chance to play with this year that would mean fun and learning for the programmer in your life. Plus, the thought of it sounded fun. Here they are, in no particular order other than the one in which I thought of them this morning: More...


When looping over collections, you might find yourself needing elements that match only a certain parameter, rather than all of the elements in the collection. How often do you see something like this?

foreach(x in a)
   if(x < 10)
      doSomething;


Of course, it can get worse, turning into arrow code. More...


The last bit of advice from Chad Fowler's 52 ways to save your job was to be a generalist, so this week's version is the obvious opposite: to be a specialist.

The intersection point between the two seemingly disparate pieces of advice is that you shouldn't use your lack of experience in multiple technologies to call yourself a specialist in another. Just because you develop in Java to the exclusion of .NET (or anything else) doesn't make you a Java specialist. To call yourself that, you need to be "the authority" on all things Java. More...


This morning ColdFusion got another mention on InfoQ, the news source for all things new and hip (or at least not normally dead and dying). The first time I saw it there was back in the summer.

I wonder if, with the new missing method handler allowing you to write even more dynamic code, and its ability to inter-operate so well with both Java and .NET, we might see a resurgence into more mainstream waters. I'd still like to see better cfscripting options available though (more than can be provided with scriptaGulous).


The next few days in Houston are busy for programming technophiles. A couple of quick reminders:

BarCampHouston 2 is this Saturday, August 25, 2007 beginning at 9:00 AM at Houston Technology Center. Update: I had the map wrong since it was wrong on the BarCampHouston wiki page. I hope no one went to the wrong place. Here is the correct one: HTC. I also decided to take the day off and chill out instead of heading up there. My apologies to anyone who had planned to say hello!

HouCFUG is hosting a ColdFusion 8 release party on Tuesday, August 28 from noon to 1:00 PM at Ziggy's Healthy Grill where they'll be giving away a licensed copy of CF 8.

Finally, Agile Houston is hosting a session with Robert Martin, object mentor on Tuesday as well. It's at 6:30 PM in PGH 563 on the University of Houston Campus.

I should be at both BarCamp and at Robert's presentation, but I'll be in class during HouCFUG's meeting.


In the past you used to give and receive advice that keeping form state in a session was a valid way to approach the problem of forms that span several pages. It's no longer sound advice, and it hasn't been for a while.

Even before tabs became popular, a few of us were right-clicking links and opening-in-new-windows. It's a nice way to get more things done quicker: loading another page while waiting for the first one to load so that you are doing something all the time, rather than spending a significant amount of time waiting. It even works well in web applications - not just general surfing. More...


Software Developer has an article, Ghosts in the Machine: 12 Coding Languages that Never Took Off that spotlights twelve of many thousands of languages that never made it big. Some had potential, others were doomed to begin with.

ColdFusion makes the list. So do Haskell, Delphi, and PowerBuilder.

I don't know that I disagree with the assessment based on the thought that "the vast majority of us all use the same dozen or so."

What do you think of the list? I was surprised to see those four languages included with some of the others, but at the same time you still have to ask, have they made it? And if they did make it, are they still there?

(via Venkat)


Let me start out by saying the NFJS conference was incredible! I went in with the intention of blogging as the sessions and days went on, but I was incredibly busy, and felt like my notes didn't do justice to the presentations. So I'm going to review the slides and flesh out my comments, and hopefully do a good job at letting you know what went down. More...


I ran into a couple of stumbling blocks today using a particular company's XML request API, and it made me wonder about the restrictions we put in our software that have no apparent reason.

My plan was simple: create a struct/hash/associative array that matches the structure of the XML document, run it through a 10-line or so function that translates that to XML, and send the data to the service provider. Simple enough - my code doesn't even need to know the structure - the programmer using it would provide that, and the service provider doubles as the validator! My code was almost the perfect code. It did almost nothing, and certainly nothing more than it was meant or needed to do.

But alas, it was not meant to be. Instead, the service provider has a couple of restrictions: More...


Today I was writing this simple function to recursively create XML based on a struct, and ran into a minor gotcha: More...


I thought I had read this somewhere, about not being able to use "cf" as a prefix to a function, but when I defined all those functions in scriptaGulous with that prefix, and it let me, I thought maybe I made the whole thing up.

But then today I was having a look through the docs for cfscript, and I found this:

Caution: ... You cannot put a user-defined function whose name begins with any of these strings within this tag:

  • cf
  • cf_
  • _cf
  • coldfusion
  • coldfusion_
  • _coldfusion
However, so far it has let me with no problems. What shall be done?


Bruce Eckel posted an article on how to use Flex with a Python back end over at Artima.

He said its possible to do the same thing "with any language that has support for creating an XML-RPC server."

In any case, I'm going to look into this in the future (I still haven't hopped onto the bandwagon). Anyone else played with it? What has been your experience?


This one refers to the 40+ minute presentation by Obie Fernandez on Agile DSL Development in Ruby. (Is InfoQ not one of the greatest resources ever?)

You should really view the video for better details, but I'll give a little rundown of the talk here. Obie starts out talking about how you should design the language first with the domain expert, constantly refining it until it is good - and only then should you worry about implementing it (this is about the same procedure you'd follow if you were building an expert system as well). That's where most of the Agility comes into play. More...


Sean Corfield responded in some depth to "Is Rails easy?", and explained what I wish I could have when I said (awkwardly, rereading it now) "I think my cat probably couldn't [code a Rails app]."

Sean makes it quite clear (as did Venkat's original post) that it isn't that using a framework, technology, or tool in general is easy or hard (although, you can certainly do things to make it easier or harder to use). In many cases, what it does for you is easy to begin with - in the case of Rails, it is stuff you do all the time that amounts to time-wasting, repetitive, boring busy-work. Rather, the right way to look at them is that they are tools that make you more productive, and it takes a while to learn to use them.

If you go into them thinking they are easy, you're likely to be disappointed and drop a tool that can really save you time before you learn to use it. And that could be tragic, if you value your time.


I never thought to do this before today, but all of the sudden I had this idea that it would be nice to have a variety of utility methods for every object. I'm talking about things like respondsTo(methodName), to see if a component has a certain method public, or inspect() as an object oriented way to do getMetaData(object), and just things in general that all objects should be able to do to or for themselves.

Rather than creating a class which would be the equivalent of BaseClassToBeExtendedManuallyByAllOtherClasses, I decided I'd like to just replace component.cfc in the CF7 install. As it happened, the component.cfc that was there (CFusionMX7/wwwroot/WEB-INF/cftags) was a 0 byte file. I just added my code for respondsTo(methodName): More...


It's been a couple of months, but cfrails has been "officially" updated (as in, I released a new zip, not just put new code into the repository).

We're a lot closer to 1.0 than one quarter of the way, so soon you should be seeing higher version number jumps. Anyway, here's what's been updated with this release: More...


Timothy Farrar brought up an issue about scriptaGulous that I thought was a good one (and one I've worried a bit about).

Should people start using the scriptaGulous library and Adobe decides to start naming functions after tags (i.e., cfQuery()), then a lot of code will break unless they start honoring your functions over theirs instead of throwing errors, as is currently the case.

He suggested using an underscore convention (_cfQuery(), and Andrew Powell proposed a tagFunctionName() style convention.

But what are the odds Adobe would start naming functions cfTagName()? Any idea from the guys over there would be appreciated, as well as anyone else with any input. Would tagFunctionName() as opposed to cfFunctionName() (or tagQuery() over cfQuery()) work better? I'm partial to the underscore method if it is needed, but obviously I prefer just simple tagName() the most.

What are your thoughts?


First I wanted to thank Andrew Powell for his gracious offer to help on this project. Then, the update:

The ScriptaGulous RIAForge page (as does the SVN repository) has a zip with a file that actually compiles now, so you can start using it in your projects.

There are a couple of tags that were removed, such as cfloop and cfoutput, where it doesn't make sense to have them (unless we decide to use closures). Some tags, such as cfmail and cfhttp include extra parameters for their respective "params." The general guideline followed is that it is an array of structs - each struct is full of name/value pairs that represent the param tag's attributes and values you want to give those attributes. Please have a look at the hints, and if they aren't clear, feel free to ask us (or tell us what doesn't work) at the issue tracker at RIAForge or the scriptaGulous Google group. More...


Last night Thomas Enebo announced on Ruby Talk that JRuby 1.0 RC 3 has been released, and that it "will likely be our final release candidate before our 1.0 release."

I'm interested to deploy a web app trying Ruby on Rails with JRuby (or JRuby on Rails, perhaps), and also in experimenting with Sean Corfield's Scripting for CF 8 to run Ruby within ColdFusion.

Anyone else planning to do good things with JRuby?


Today I put some code into the scriptaGulous repository at RIAForge. (scriptaGulous is a function library that intends to duplicate all the ColdFusion tags (where it makes sense) to make them usable in cfscript blocks).

Basically, I wrote a generator to read the taglib.cftld and generate some code for us to start with. I was going to generate some unit tests too, but I've got to move on to doing some other work.

Anyway, I'm sure plenty of the tags/functions actually do work, but when you cfinclude scriptagulous.cfm, you'll get attribute validation errors in some of the tags.

So now on to the next stage of development: making all the tags work. For that, we need your help! (if you want to use this sooner rather than later) If you'd like to commit to contributing a tag or two (or more!), please join the scriptaGulous Google Group and record which tags you're working on so we don't duplicate our efforts.


That's ScriptaGulous with a big-G (not C). The name is kind of cheesy but there's been a lot of talk lately about being able to have all the tags available for scripting in CF. This is something I've wanted personally for a while as well, and it has been on my to-do list for quite some time (ever since 11/22/2006 after a conversation with Ron Jeffries about how "agile" a tag-based language could be on the XP Yahoo! Group). It's been there for so long with no action on my part, I thought starting a project page at RIAForge would get me moving. It's certainly not going to be a particularly hard project to do, as most of it is repetitive busy-work, but I think it will be very useful. More...


Often when we make a change to some code, if it is not properly designed, the result is that cascading changes need to be done throughout the application because bugs will ripple through the system. That's one of the ideas behind why we want to have low coupling between classes. We also have unit testing to combat the effects of this, but let's just suppose we haven't written any, and haven't used JUnit Factory to create regression tests.

Given that there is a lot of code out there that isn't quite perfect, wouldn't it be nice to have a tool that could analyze changes and where they would affect other code? I can imagine how such a tool might work, but I haven't heard of one before now (that I recall, anyway).

So the point of it all: I heard something about BMC and IBM teaming up on such a tool (my understanding is that BMC started it, and IBM later joined the project). I'm assuming it'd be in Java, but does anyone have information on this? Can anyone confirm or deny the story I heard?


Ok, this is a well known issue (and I feel like a moron for it taking me so long to figure out), but I couldn't figure it out for the life of me (I was looking in the wrong spot the whole time - who would think CF Studio had anything to do with it?).

For the longest time, my FTP was not working, and today we finally narrowed it down to Allaire FTP & RDS. The only problem is, I couldn't set up an FTP site on it, and I couldn't uninstall it (in fact, it looked about half-uninstalled, as it remained under "My Computer" but the icon was dead and you couldn't do anything with it. More...


What if we had functions compile(String sourceCode) and runCompiled(BinaryData compiledCode)? What could you do with it? Could it act as a closure, and bring really dynamic coding to traditionally static languages, perhaps allowing dynamically named variables and functions to languages without them (and much more!)? Could we store our code in a database and mix and match chunks, building programs based on a SQL query?

What do you think? Useful or useless?


Peter Bell's presentation on LightWire generated some comments I found very interesting and thought provoking. (Perhaps Peter is not simply into application generation, but comment generation as well.)

The one I find most interesting is brought up by several people whose opinions I value - Joe Rinehart, Sean Corfield, Jared Rypka-Hauer, and others during and after the presentation. That is: what is the distinction between code and data, and specifically, is XML code or data (assuming there is a difference)? More...


I've been thinking about it lately, and I cant't seem to think of any (in my admittedly small set of knowledge) other language that allows you to be dynamic by leaving out language constructs (such as the type and returntype attributes of parameters and functions), but that, when you do decide to use them, the language acts statically (and is CF even acting statically when it checks the arguments, or is it acting strongly?).

For all you supermultilingual coders out there: do you know of any other language which is dynamic, but allows you to instruct it to become static like CF does? If there are others, is CF the first? More...


It might be petty, but those two three-letter words really get to me. They clutter my code almost as much as semicolons, Object obj = new Object() // assign a new object to the object called "obj" which is is of type Object, and angle brackets. I'm want to do something like newCodebase=rereplace(entireCodebase,"[gs]et","","all").

What if we had a new idiom where calling the method without arguments would cause it to return a value (the get), while calling it with an argument would run the setter? Its easy enough to do. What do you think, am I off my head?


As I'm getting into little details about the generation cfrails is doing, I had a couple of questions I thought the community could provide some insight on better than my own experiences regarding lists.

One of the great things about generating this stuff is that you can have for free all the bells and whistles that used to take a long time to do. In particular, you can have sorting on columns automatically generated, as well as pagination.

So question 1 is: given that you can have sorting for free, would you rather automatically sort on every column, and specify any columns you did not want to sort on, or would you prefer to not have sorting placed automatically, but just specify which columns to sort on?

And question 2: Given that more and more people are on broadband, is it time to up the 10-record limit on results? I find it annoying to have to reload all the time, and if given the option, I normally up the results/page to 50 or 100. What do you think, would you make the default number of results/page higher (and how high would you take it?), or would you cater to the lowest common denominator?


As expected, Ben was a great speaker and gave a good presentation. He said we were quiet, and someone said its because we've read all the blogs about it before he came. He was running a little late, due to some fiasco in Austin where the city commandeered the meeting room and they had to change the venue at the last minute.

Unfortunately, Dave's post about the presentation did act as sort of a spoiler, and Ben didn't give us any scoops (that I noticed). Anyway, that's why I don't have much to add. =)

One important thing though: so far, they have yet to get an error on CF8 running old CF6/7 code (some public facing parts of adobe.com are running on CF8 now, he said). Of course, this is what you would expect, but I remember the nightmare we had moving from 5 to 6 - it wasn't pretty.

Seeing the presentation live did give some perspective to Dave's notes, and it's worth going even without learning anything new. I also wanted to thank the HouCFUG guys for putting all of that together- you guys did a great job (and it was good to meet you!). Finally, congrats to the winners of the raffle prizes. I guess I'm going to have to break out the wallet when 8 comes out. I think I'd buy it just for the inline arrays and structs.


Thanks to Dave Shuck's post about Ben Forta's presentation at Dallas/Fort Worth CFUG, I now know a lot more about CF8 than I did before. He has a long list of new features, but the two I'm most excited about are inline arrays and structs! Dave showed a couple of examples:

<cfset MyArray = ["CFIMAGE","CFWINDOW","CFPOD","CFMENU"] />
<cfset MyStruct = {Name="Dave",FavoriteLanguage="CFML",Cool=true} />


Now, if we could just get closures ... =)


There are a couple of drawbacks (or some incompleteness) to scaffolding being truly useful. The one that seems to be most often cited is that normally (at least in Ruby on Rails, which seems to have popularized it) it looks like crap (it is only scaffolding though). Of course, most who make that complaint also recognize that it is only a starting point from which you should build.

Django has been generating (what I feel is) production-quality "admin" scaffolding since I first heard about it. It looks clean and professional. Compare that to the bare-bones you get by default in Rails, and you're left wondering, "why didn't they do that?" Well, as it happens, it has been done. In particular, there are at least 4 such products for use with Rails: Rails AutoAdmin (which professes to be "heavily inspired by the Django administration system"), ActiveScaffold (which is just entering RC2 status), Hobo, and Streamlined (whose site is down for me at the moment). More...


For more info, see this post or HouCFUG.

The meeting is at 6 pm. And here's a map.


Base on the suggestion from Rob Wilkerson, I decided to pull this out into some code that illustrated the point I made in my last post. For context, see Another great use for closures.

Basically, what's going on is that we have a list() method that takes a query and dynamically outputs a list of its rows (with a heading column as well). It also has the ability to call a closure for a cell instead of doing its normal output, if one exists. More...