Wednesday, February 28, 2007

The Evil and Annoying WHITE SPACE

I hate white space. I loathe white space. There are very few things I will say that I hate, and white space is close to the top right now. It has been the cause of countless mind-numbing hours of work on projects at my job and in school.

The two most recent encounters with the villain have occurred over the past two weeks. The first error happened while I was working on my web service project, which I developed in PHP. You can read more about it under the Information Architecture section of my blog. The lesson I learned: Do not leave any extra white space before or after the php tags (). If you do things will go haywire.

The second occurrence was yesterday. I spent an extra 2.5 hours at work trying to figure out why to hostnames, when compared, were exactly the same but the php script thought otherwise and completely skipped over them. I looked at every thing that could possibly be wrong and had absolutely no luck. The thought then occurred to me, "Could there be some white space lurking about in some dark corner of my script?" I added the trim() function (a function in php that strips both sides of a string of any white space) to the variables being compared, and sure enough, it worked. The "in-famous" white space had struck again.

I guess you could count my encounter two weeks ago as some sort of a blessing, as my mind was still some what fresh on the frustrations white space had caused me before. Hopefully these experiences will be engraved in my brain so that in the future I will be able to diagnose the problem more fully. On the other hand, it was kind of nice to see how easily the problem could be fixed, and that once the white space was eliminated, the program worked perfectly!

No comments: