Aarrgghh!!

One guy's take on the web, programming, cigars, politics, Philadelphia, and whatever else comes to mind.

March 2007 Archives

Whitespace - What's the big deal?

March 29, 2007

This came up in a code review today. There were a couple misunderstandings about it, so I figured I would share the explanation publicly.

First, there are two types of whitespace what are in play here. Whitespace in your code for the purpose of properly formatting, and extra whitespace in your ultimate HTML output that comes from the various loops and other mysterious sources in ColdFusion. In simple terms, the first is good and the second is bad. However, you shouldn't try and get rid of the first in order to get rid of the second.

First, to see a demonstration of what I am talking about, go to Wharton Computing's Brainstorm. Once you're there, "View Source" from your browser. At the top of the page, you'll see a few lines of empty space before the DocType declaration. Select them with your cursor. You'll see they're not just page breaks, but spaces and tabs.

Now, go to the Wharton Wireless Troubleshooter (WWT). Do the same thing. You'll notice a lot more whitespace at the top.

(I'm not picking on some random developer; I did both of these applications.)

That's the easiest way to show you what I'm talking about. That whitespace makes the output HTML page bigger, as each piece of whitespace is a character that you are sending to you user.

Well how much of a problem is that little bit of whitespace? Well frankly not much, but if you understand how it gets created, you realize it can become a very big deal.

It gets created in loops that, in the case of the WWT, are being called before the header is rendered. (It can happen anywhere in a page, but that's where it's happening in this application.) So in the case of the WWT a few loops are generating say 1 character of whitespace per iteration. But suppose for a moment that you were doing hundreds or thousands of iterations... In multiple loops... with multiple characters per iteration... in multiple included files.

Like everything in coding, it's not that one little thing is so bad, it's that the little bad things tend to aggregate together, form large bad things, gain sentience and run amuck!

So what can you do to prevent whitespace? I could tell you. But Ray Camden does such a better job of it in his article about whitespace.

I would just add two things.

  1. Ray mentioned a whole bunch of techniques you can use to reduce whitespace, but he doesn't say what not to do to reduce it. (Awkward sentence, but bear with me.) You should not start formatting your source code to reduce the number of lines you use, the number of tabs, or the number of spaces. Readability of your code is still extremely important. Don't change your code formatting to fix your html formatting. Find the spots that generate the whitespace. Then utilize the techniques he mentions to treat the problem topically. (My favorite method is to insert the <yo /> tag randomly throughout the source.)
  2. If you're not sure if you have this problem with your page, or if you're not sure how big an impact the whitespace is having, use the tools at Web Site Optimization to see how big your output page is. Alternately this can be accessed via the Firefox Web Developer Toolbar.

March 29, 2007 Posted by Terrence Ryan at 5:28 PM

ColdFusion, Web Development,

Jupiter Rising

March 28, 2007

I have found reason 531 to be glad I switched to developing in CFEclipse. Its name is Jupiter. It's a code review tool for Eclipse. I find myself in complete disbelief, but I think I love a code review tool.

Why? What does do that makes me love it?

  1. It links annotations directly to the code via line numbers.
  2. Because of that linkage, you can open the code directly from the code comments.
  3. It allows several levels of severity and categories of comments.
  4. It allows for teams to collaborate on code reviews.
  5. It saves notes in an easily parsed XML file for external reporting.

Dave and I are experimenting with it. It looks like it will make all of the code reviews we have to do a little easier.

I have to thank Kola Oyedeji who made some observations about a previous post of mine regarding code reviews.


March 28, 2007 Posted by Terrence Ryan at 8:21 PM

ColdFusion, Web Development,

Squidhead Swims On

March 27, 2007

I've done three updates to Squidhead since the last time I blogged about it. Two of them were pretty major so I figured I would squawk some more about it.

First, I haven't forgotten about adding support for other DBMS's other than Microsoft SQL. I haven't done it, but I have re-architected Squidhead slightly to make it a bit more possible to do so down the road. There's one more step I need to take to open that up, which is focusing on primary key's rather than identity. I know it should work, but I'm just not ready to pull the trigger on it.

Second, I've added quite a few features around the main unique feature of Squidhead, stored procedures. The whole focus of Squidhead is pulling in user created stored procedures and creating the ColdFusion code to support them. The recent changes I made allow Squidhead to properly handle store procedures that return multiple result sets. Alternately it can handle multiple output parameters, from the stored procedures.

Third, I've got a Build a Blog in 15 minutes presentation in the works. It's a respectful homage, to Joe Rinehart's YouTube presentation on ModelGlue. I figure it's effective in getting the feature set across, and appropriate since Joe's presentation got me into code generation and frameworks in the first place.

Finally, I have a pretty good idea of what's coming down the pike for Squidhead. Before I add support for other DBMS, I'm going to try and flush out the feature set, so as to avoid writing multiple versions in tandem. I prefer to port over the full version to other databases. My current list of updates includes support for foreign and primary keys. I'm also looking to add some form validation. That being said, if anyone has any thoughts, I'm very open to them.


March 27, 2007 Posted by Terrence Ryan at 8:07 PM

ColdFusion, Squidhead, Web Development,

JVM Update and LDAP SSL

March 13, 2007

I had a problem this week due to recent updates for DST. LDAP over SSL stopped working. It took me a fair amount of time to track down the answer, so I figured I would share.

Basically, the secure certificates store is tied to the JVM, not to ColdFusion or even JRUN. So when you update the JVM you lose a bunch of Certificate Authorities in your keystore (I assume since the file is so much smaller) and you lose any custom Certificate Authorities you may have added.

I found the solution at via a Google search at sagewire.org (JVM upgrade breaks secure CFLDAP connections), but basically the solution is to copy your former copy of the cacerts files to the new JVM's location, then restart ColdFusion.


March 13, 2007 Posted by Terrence Ryan at 11:56 AM

ColdFusion, Web Development,

Scorpio in August?

March 7, 2007

I don't know if anyone checked out the new Scorpio wallpapers posted by Ben Forta, but in the lower right there is a line "<8 : 2007 >." (See the blue wallpaper .)

I seem to remember reading this speculation somewhere else, but a quick Googling yielded nothing. I think that's a pretty decent sign that Adobe is targeting August for ColdFusion 8. Woohoo. Good news to those of us that want to deploy apps for a new school year.

Either that or they're screwing with us. If that is the case I say: "Shame on you, Tim Buntel. Shame."


March 7, 2007 Posted by Terrence Ryan at 11:34 PM

ColdFusion, Web Development,

Poor, Slightly Misunderstood, Squidhead

March 5, 2007

I finally got around to listening to the ColdFusion Weekly Podcast on February 12th. Squidhead was mentioned - WoooHooo! Wait a minute from the description it seems like Squidhead just creates CRUD + list stored procedures. The key to my disappointment is the word "just." Squidhead doesn't just generate stored procedures. It also reads in stored procedures that you create. So sure, it scaffolds the basic CRUD and list actions building stored procedures and CFC's but also builds CFML from user defined stored procedures.

So for example, you have a table, person, with columns personid, username, password, first and last name. You run Squidhead once, you get the 4 CRUD procs, plus a DAO CFC to call them, then you get a list proc, plus a gateway CFC to call them. But then you go back and write a procedure "usp_person_select_by_username" because you would rather do that then select by identity. You run Squidhead again; it adds "select_by_username" function to the person DAO CFC.

But let's take it one step further, suppose you write a stored procedure named "usp_person_auth" that takes the username and password and checks them as an authentication routine. Run Squidhead again. You'll now have an "auth" function in your person gateway CFC.

The idea here is to do the database work in the database, and not have to do the manual work of writing the cfml calling code. Sure, it creates stored procedures, and that is a leg up, but it also lets those of us that like starting in the database an even higher leg up... (not sure if that's the right modification of that metaphor.)

Anyway, don't take this as a swipe at Matt and Peter. I'm glad to have some exposure in the ColdFusion Weekly Podcast. It's my bad that I haven't been publicizing Squidhead better.


March 5, 2007 Posted by Terrence Ryan at 10:31 PM

ColdFusion, Squidhead, Web Development,

Blogging from Imified

March 1, 2007

I'm just testing out the whole blogging from IMified Interface. It looks like it has a lot of promise.


March 1, 2007 Posted by Terrence Ryan at 4:33 PM

ColdFusion, Web Development,

CAO Maduro Toro

I'm working from Mahogany and trying new stuff. Enjoy the goodness that is the CAO Toro Maduro review... after the jump.

Continue reading "CAO Maduro Toro"


March 1, 2007 Posted by Terrence Ryan at 4:18 PM

Cigar Reviews, Cigars,