Rants

10 Ways To Suck At Programming

I recently inherited a web app from a dirty, nasty, stinking contractor that claimed to be a competent enough programmer to be left alone to get things done. Unfortunately, we took him at his word. Functionally, most of the web app seemed to work at first glance. However, once the client took over the reins and actually started using it things went downhill fast. The contractor disappeared after payment (die reputation DIE!) and I was left to try and get things working properly and performing up to snuff while the client limped along with what they had been given.

I decided to document a few of the things that I found wrong along the way.  These are really just things that every good programmer should already know to avoid… but obviously some people need to be reminded (or taught).

Update – 05.18.2010 – Some people thought that this article was too sarcastic.  While I thought it wasn’t sarcastic at all, it does exactly what the title promises and teaches people to suck, I’m always game for being constructive.  So I wrote an offset to this article – 10 Ways To NOT Suck At Programming.

#10 – Don’t store settings in a configuration file

When you’re writing a sizable application, things like database connections and SMTP server information will be used throughout the app.  The best way to make sure your app is entirely immune to maintenance is to redefine those little bits of information every time you need them.  So instead of putting them in the configuration file (Web.config or whatever) just leave them in your compiled code.  Whoever inherits the app will thank you for sending them on a hunt through thousands of lines of code to change which SMTP server is being used.  What’s even more fun is when the next programmer only finds 14 of the 15 places where you’ve used this code and a single instance somewhere deep in the app silently breaks hundreds of times without anyone knowing.  Sometimes it’s helpful to build the variables in inconsistently concatenated strings. The repeated and more frequent interaction between the new developer and the disgruntled client will help strengthen their relationship.  And if you don’t hook up that love connection, who will?

#9 – Don’t store variables in [any] memory scope

One of the great things about databases is they store your bits of information and allow you to access them whenever you need them.  To make sure your app is as terrible as possible, you’ll want to be sure and access the database every time you need a bit of that information.  The more common the information is that’s needed, the bigger win you’ll have by making a new database connection to get that information.  Non-sensitive user information is a great use of this prinicple.  Don’t worry about defining a user’s information, such as “isAdmin” to a variable and using it throughout the current request.  Just query the database each time you need to know anything about the user.  After all, the client paid for that database, we’d better get as much spin out of it as possible!

#8 – Use arcane plugins

If the client has a non-standard request, such as formatting a table in a way that is outside the abilities of your WYSIWYG editor (colspan are hard).  You should definitely hit up the interwebs and search for random unsupported closed source plugins to do the work for you.  If you would spend almost an entire hour writing it yourself, you should spend at least 3 hours searching for and getting a plugin that does roughly but not exactly the same thing.  Bonus points if you can get a plugin that doesn’t do what you need, but offers 15MB+ of functionality you have no use for and include it without getting caught.  Bonus bonus points if the documentation for that plugin is in a language not native to your market (for example, if you’re working in an English speaking shop look for plugins that are documented only in Spanish or German).

#7 – Never, ever remove functionality

Over the course of developing a large application there are bound to be times when functionality you were working on proves itself to not be needed.  Now, to be sure to leave plenty of dead ends for those who come behind you to get lost in, never delete that functionality.  Maybe even comment out random parts of it, or even hundreds of lines of it at a time, but don’t delete it.  Imagine the hours of fun the future-crew for this app will have while they trace through this functionality only to find that it isn’t needed!  If you can make it seem needed, without actually needing it, it will even keep them from deleting it themselves…  This way the fun is exponential!  Oh, a bonus on this one… if your project uses source control and multiple server environments, be sure to have a different version of your files (both code and compiled) on each server and source control.  This way no one will know which one is live in production and who doesn’t love a good round of Code Russian Roulette?

#6 – Screw performance

Large applications, you know, the ones that pay the bills, are generally needed because they deal with large amounts of data.  Sure, during your development process you’ll create 20 or so test records.  Take my word for it, there’s no need to even worry about what happens once you get to 25 records, or even 1,000!  Obviously, all pagination will work just fine and performance will never take a hit.  So if it compiles, ship it!

#5 – Nest major logic/functionality in loops

Now obviously, we’ve already covered #6 so we know that we’re working with large amounts of data.  And inevitably, there will be plenty of looping through that data to do work with it.  If you want to make sure your application is really difficult to maintain and completely unusable to the client, you should embed major functionality and/or logic inside of these loops.  For example, instead of running a query against the database to get ALL the data you need, storing the data in memory and working with the variables in memory during your loop, just get all the data except one field up front and loop through it… then on each loop you should get all the data again, and now include your extra field.  This will guarantee that your app will never survive more than 5 concurrent users (re: #6).  So for review:  Get data > create loop > get data > work with data.  I’m sure you see some room for added idiocy in that process, so feel free to nest this idea as many times as you want.

#4 – Document NOTHING

Look, documentation is for morons.  I mean either you can read the code or you can’t, right (this was actually said to me at one point)?  Of COURSE the next programmer will be able to read the code.  What’s really fun though, is when you document absolutely nothing, especially not your intent.  It pays to keep them guessing.  You’re mysterious, like a ninja.  No need to let someone get all up in your grill, knowing everything about what you were trying to do.  Because if you document what you’re trying to do and then don’t end up doing it… well… that’s just embarrassing.

#3 – Use and reuse illogical variable names

There’s going to be a LOT of variables needed to work on this app, so you’d better choose a movie or television show with enough characters to use all the names.  Lord of The Rings, Star Wars and Family Guy are all good choices for this.  Maybe you can even form relationships with the variables.  That way, you never have to kill them!  You can have variables that are chameleons, changing their usage and values throughout processing and you can recycle them for something new each time you need a variable for new functionality.  It’s like they’re growing up, evolving, right before your eyes!  After all, you’re trying to be green and reduce your carbon footprint so recycling variables just seems like the responsible thing to do!

#2 – Catch all errors — and do nothing with them

Most languages / platforms nowadays have really good error handling built in.  They’ll die somewhat gracefully and give enough details through the default error output to be helpful.  You must not allow this to happen!  Start off by wrapping nearly every tiny piece of functionality in a try / catch phrase.  Then… inside the catch… put a comment, like “// It borked lawl.”  This will ensure that if anyone wants to work on this app, they’d better spend the time getting to know the app and it’s adorable character variables before they start wrecking the app altogether.

#1 – Duplicate functionality

If the client tells you that they need two pages:  One for an administrator that has all of the details on an item along with a button to delete it; and one for a regular user which has all of the details on an item without a button, you should create multiple pages to accomplish this.  In fact, if you can make pages for each user group that would even be better.  Making a separate page for each user is the ultimate success.  So ninja up and get serious on this one, because it’s your last line of defense against the teeming hordes of qualified individuals who will inevitably be bewildered while trying to update your carefully constructed Pandora’s box of an app.

This is by no means a comprehensive list.  On this project alone I could name 10 more things that could make you suck.  But I’ll leave it at 10 for now.  Anyone have more to add?

1&1 Hosting – Your Tech Support Sucks!

I’m frustrated.  I just spent nearly half a day setting up a site for a client to get ready to “go live” soon.  Setting up the site on their already existing, shared hosting account with 1&1 Hosting was part of the final round of things to make sure we were good to go.

Here’s the situation.  The client has two domains hosted on this account (1&1 promises you can have as many as you want).  The new site I’m putting up will replace one of the existing sites when the client is ready to pull the trigger.  So my approach was to set up the site in a new directory and create a “dev”.theirdomain.com sub-domain to point to it.  This is pretty standard practice and it allows me to check the site on the server it will eventually live on instead of just throwing code at an unfamiliar server and crossing my fingers.

So I used their handy-dandy control panel to create the sub-domain and point it to the new directory.  Then I pushed all of the files to the new directory via FTP.  All of the *.shtml files worked, but any time I tried to call a *.aspx file I would get a 404 error.  Odd… I know they’re there…  So I spent an hour or so poking around their control panel looking for something I may have missed.  Oh, there’s a way to create an “application” out of a directory but you can only have 5 of them.  Surely that’s it.  Nope.

So, defeated, I caved and decided my last heroic productive act of the day would be to call their tech support.  After a short wait, I get “Jean” (pronounced like Shohn) on the phone.

Me:  Hey Jean, I’m trying to get a sub-domain set up so I can run some .NET files.  Everything seems to be working, I can access any of the .shtml files but none of the .aspx files work.  I get a 404 error!

Jean:  You need to make redirect scripts on your main domain.

Me:  Well… that would take down the pages on the main domain and I really don’t want the client’s live site to go offline.

Jean:  (le sigh) It will work, you need to create redirect scripts on the main domain.

Me:  I understand that creating redirect scripts will work to forward traffic to this new site.  But are you telling me that for every aspx page I have on the new site I have to create a redirect on the old site to forward it over?

Jean:  Yes

Me:  That can’t be right.  Maybe I misstated my original question.  Let me try again.  I have created a sub-domain and pointed it to a directory at the same level as the other site.  Everything is running on it just fine, except for any page that is a .aspx page.  All .aspx pages give a 404 error whenever I try to access them, which isn’t good because the default page is… well… Default.aspx.

Jean:  (aggressively) You should create redirect scripts on your main domain.

Me:  Yeah thanks, bye. *click*

Seriously guys.  Your tech support sucks.  I’m going to try again tomorrow, but if the answer truly is that you are unable to enable .NET for sub-domains then your hosting service sucks too.

Windows 7 Boots Slow – Check Your Wallpaper!

Let me start by saying I have a monster of a machine.  I use it for more demanding tasks than most people will ever ask their computer to do and it performs all of them admirably and quickly, all in 64-bit glory.  Then, I upgraded to Windows 7.

Now, at first, things were unbelievable and I was in love.  And truth be told, they still are and I still am, except during the boot sequence.  Whenever I boot, the OS takes forever to load.  It literally just sits, no disk activity, no notable processing, no informative messages on the screen, nothing.  And then, all of a sudden, everything loads almost instantly.  It’s almost as if there was an intentional delay or something.  Suspicious, right?

So I started researching this today.  I’m not exactly sure why it surprises me but apparently there is a bug in Windows 7 that causes a 30 second delay during boot if you use a solid color as your wallpaper.  Silly me and my minimalist approach looking for better performance.  I thought not loading a wallpaper would be easier for the machine to do than loading one.

I found the original article over on Lifehacker.  Within that article they provide links to a hot fix and some workarounds.  But I figured creating another article couldn’t hurt, just so people would know what was up.

Adobe Photoshop CS2 on Vista – The Horror!

I had no idea that getting Adobe Photoshop CS2 to work on Windows Vista Home Premium was difficult. As a matter of fact, as someone who has been using Photoshop for many years I assumed it would be easy. Silly me. Following is my account of dealing with Adobe Support to try and get my legal copy of Adobe Photoshop CS2 to work on my new machine, which coincidentally came with Vista Home Premium. Note that the issues I experienced had nothing to do with Photoshop functionality, the only problem I had was getting the software to accept my serial number.

The Back Story

I’ll start by describing my situation. It wasn’t one that I initially thought was odd, but Adobe’s support personnel have had one hell of a time wrapping their mind around it so I can only assume that my situation is mind (and possibly time, space and physics) bending.

  1. I have owned and used Photoshop CS2 since 2005
  2. I recently purchased a new computer from Dell, it came with Windows Vista Home Premium (so I decided to try the much maligned OS)
  3. I wanted to install, register and activate my copy of Photoshop CS2 on my new computer

The Assets

Now that you have a little back story, I’d like to tell you how I’m set up just to be sure there’s no misunderstanding (again, Adobe support couldn’t fathom this setup).

  1. My new computer is a hardware monster, it dwarfs the minimum requirements for Photoshop CS2 from a hardware standpoint
  2. I still have the original download of Photoshop CS2 that I got from Adobe on a CD (I thought it was pretty standard to back up purchased and downloaded software, apparently it isn’t)

The Problem: Part 1

Now for the fun. While I was installing Photoshop it asked me for a serial number. Like a good customer and someone who writes software for a living I don’t keep a copy of the serial number along with the software install. Instead, I depend on Adobe to keep up with that for me. So during the pause in the installation I headed out to Adobe’s site and logged into my account to take a look at my serial number. When I got to the appropriate page, however, the site informed me that the registration services were not available.

“No problem” I thought, and continued to click the “Trial” button to go ahead and install Photoshop CS2 so I could use it for the task I needed and activate / register it later once the registration services were back online. Logic has been the downfall of many…

The Problem: Part 2 – The Problem Grows

I finished my task with no problems, saved my graphics files and continued on about my way comfortable in the knowledge that soon Adobe would be back online and everything would be tidied up.

So the next day before I head out for the day I check on the registration services site again only to find that it’s still down. I figured what the heck, I’ll call their support center. The conversation with the support personnel was pretty short… as she informed me that she couldn’t help me because the registration service was down.

“Well that’s less than ideal, but whatever…” I thought as I headed out the door.

Online Support

At some point during my day that day I had a thought, “I might as well submit an online ticket so the nice support folks can get to my problem as soon as the flaky registration service comes back online.” So as soon as I got home I sat down and submitted a support ticket using Adobe’s site.

Two days later (on Monday, which is fine, they don’t work weekends) I got an e-mail with a PDF attachment… apparently this is how Adobe’s support communicates… via an e-mail with a PDF attachment. What a clever way to try and force people to use Adobe Reader. Anyhow, the gist of the message was that they would be unable to help me because it was a weekend (note that this was sent on Monday). However, the message continues on to tell me that my Photoshop CS2 serial number will not work with Photoshop CS3. They then continue to assure me that they were happy to have solved this issue for me.

Of course, CS3 had nothing whatsoever to do with my problem, so I responded. Admittedly it took me until the next Saturday to do so (after all, the trial was working, getting it activated wasn’t my top priority). I was pretty straightforward but polite in my response that CS3 was nowhere to be found. I even used Photoshop CS2 to make the image below and attach it to the support ticket. You see, the only problem I had is that I couldn’t enter my serial number… nothing else was wrong!

The image I sent to Adobe\'s Support

On Sunday (the next day, at least these guys are prompt) I got a message informing me that it was the weekend. This time, however, I was instructed to call Adobe’s support telephone number instead of bothering the online support folks, they said the phone support personnel would be better qualified to handle my unique issue.

Telephone Support

So on Sunday I went ahead and called the Adobe support folks again. I got a nice individual on the phone who seemed genuinely eager to help me solve this issue of epic proportions.

Of course, all he could tell me was that Photoshop CS2 does not work on Vista, I need to upgrade to Photoshop CS3. After me spending 20 minutes trying to convince him not only did it work, but I used it to make the attachment on the ticket, my support tech was ready to get rid of me. He told me to call back some other time, when the technical support folks would be around. I had to wonder who exactly I had been talking to all this time if not technical support.

Going Rogue

The time had come for me to put some of my own time into solving this problem. In all honesty, it wasn’t that hard to solve once I put my mind to it. I had originally hoped for a quick fix from Adobe but once it was obvious they were not going to be of help… and that my trial would run out… I had to figure out how to make things work on my own.

I researched the problem on the web and found some vague references to it, but nothing that out and out told you how to fix it. Thus this article…

There seem to be several approaches to fixing the problem that people have found over time. However, I found what worked for me and it goes a little something like this:

  1. Uninstall Photoshop completely
  2. Disable Vista’s UAC functionality
  3. Re-install Photoshop CS2 in Windows XP SP2 compatibility mode
  4. Enter your serial number during the initial installation
  5. Run Photoshop CS2 in Windows XP SP2 compatibility mode

I will add a more detailed post at some point in the future which outlines each of the steps in detail, possibly with screen shots if I find the time (now that my copy of Photoshop isn’t going to expire).

Note that I was never able to get the “Activation” popup in Photoshop to work, it would always give me the error listed in the picture above. However, the first time I used my serial during installation using the steps I just outlined everything seemed to work great.

The Conclusion

Adobe Photoshop CS2 does, in fact, work on Windows Vista Home Premium if you’re willing to toy with it. Of course, having to toy with it is the reason I don’t use Photoshop’s competitors.

Anti-war protests… Where are they?

I stumbled across an article hosted on Slate today written by

France is in trouble

This article actually started about three years ago, when a coworker and I were discussing the move by the French government to outlaw the word “e-mail.” At the time, in 2003, I found it very odd that a government would be taking such drastic measures against a seemingly low payoff end (there’s no way to enforce it and people are going to call it what they call it, regardless of what they should call it). During our very casual lunch conversation, I mentioned how odd I found this and a discussion began that intrigued me even more than the French government’s seemingly misplaced energy.

As it turns out, this coworker’s father was a very, very high ranking official in the U.S. military (yes, I verified it). As part of his responsibilities he maintained contact with officials from all European countries, including France. Not long before our discussion my coworker’s father had been discussing with his son the sad shape the French government was getting itself into.

According to him, France was losing all cultural identity. The constant concessions shown to special interest and minority groups had begun to give those groups powers which far outweighed their position within the society. In turn, the majority of the society was bearing the brunt of the loss of their power. The minority and special interest groups were holding much more sway than would normally rightfully be theirs.

After our discussion, my coworker revisted the issue with his father and mentioned our discussion. His father’s take on the issue was… again… interesting.
More >

Ray Beckerman interview

Who is Ray Beckerman? He’s a lawyer attempting to defend people against the blanket, John Doe style lawsuits the RIAA is perpetrating all over the place. I’ve only kept up with this information in a general sense (compared to some others I know) but haven’t seen any information on the lawsuit side as detailed as what he provided in an interview he did with DefectiveByDesign.org.

Probably about 10 minutes of reading that will enlighten you to some pretty interesting stuff:

http://www.defectivebydesign.org/node/404

RIAA finally defeats allofmp3.com?

In what can only be described as unsurprising the U.S. Government has released a document which outlines a new relationship with the Russian government that will rule how the two interact based on intellectual property.

I didn’t provide a link, because the one I found was a PDF. Check here if you would like to read it.

I’ll summarize as best I can without causing an unnecessary loss in interest to those who are barely hanging on anyway, but nothing beats reading the original for yourself if you are someone who is interested.

The gist of the document is that Russia has agreed to begin to more aggressively chase down and penalize the people who would allow others to gain what the U.S. government would consider “intellectual property.” The most interesting thing about the document, of course, is that on page two, the first bullet point specifically names allofmp3.com as a target. Among other interesting, valid and needed points it seems questionable that allofmp3.com would be specifically targeted. Anyone who has ever been to Russian can tell you about the rampant illegal CD sales that go on, surely there were factories making these illegal CD’s which could be named as well? Instead, those points are glossed over and vague enough to actually allow continued violations while allofmp3.com takes the brunt of a direct reference, assuring that they will be specifically targeted and made an example of.

While I would be hesitant to say that the negotiations are in direct response to RIAA’s repeated demands even in the face of Allofmp3′s repeated justification it is hard to ignore the constant crowing the RIAA does about the site. Why would the U.S. government have any interest in specifically naming allofmp3.com as an enemy unless it is because of the constant complaints from the RIAA?

Now don’t get me wrong. While I like the idea behind allofmp3 much better than the blatant ripoff (I’ll write an article about that soon enough) that is our DRM overlords, I think the idea has been taken to an extreme and as such doesn’t compensate artists properly (or at all, actually). As such, it isn’t an acceptable solution to everyone and some changes should be in order.

I guess this is just another case, building on the suing of minors and people who don’t even own computers, which points out the complete and utter failure which is the RIAA. At some point artists are going to realize that they can make much, much more money by selling the bandwidth to download their songs rather than paying the RIAA and its minions to market the songs for them. I, for one, will be glad when the money I spend on music goes directly to the artist who created it instead of the executives who greedily mark up the prices to distribute the music.

Do the math… the DRM controlled music you buy is a ripoff.

If we can’t fix pollution, we should make it worse!

Today I came across an article on CNN where Kofi Annan presented a proposal to the U.N. Climate Change Conference that indicates a possible solution to global warming is to create more polution in the air, thereby creating a sort of “shade” around the planet which would filter the sun’s rays.

I’ve seen the idea referred to as the “global haze proposal.”

To be sure the article doesn’t escape (CNN has a habit of moving their articles after a while) I’ll include the full, quoted text here:

More >

SQL Management Studio… How NOT to save in Unicode format

A project I work on requires that we developers edit stored procedures and store the resulting script in a text file that we put in our source control tool. In our case, we use Microsoft SQL Server Management Studio to do the aforementioned editing and we use CA’s Harvest Change Manager as the corporate mandated code repository and source control tool.

Now if you were using another tool, Notepad or Query Analalyzer, for instance, you probably wouldn’t have the problem I’m going to outline. As a matter of fact, the problem I’m going to outline is probably pretty rare. But it exists and I found a solution, so I’m going to write about it.

As it turns out, whenever you “Save As” in Microsoft SQL Server Management Studio the default encoding for the file is Unicode – Codepage 1200. Yes, this is a new approach to saving your beloved stored procedures and no, it wasn’t done that way in the past. Further, I can’t find any notification that the “standard default” was going to be changing.

Anyway, Harvest doesn’t like Unicode files. So when you go to add the file to your Harvest project it won’t let you. Oh, the humanity! ANSI for everyone!

Now I may be in the minority here, but I originally failed to notice that on the “Save File As” dialog there is a small arrow on the right side of the [Save] button. Once I noticed it, I clicked it… Then I clicked “Save with encoding…” Now I’m happy again! Kind of…

The good thing is that this will let you save your file in whatever encoding you want. The caveat is that it will let you save your file in whatever encoding you want.

So how is the default set? I’ll leave that for another article… Mostly because I don’t know yet.

Update (04.11.2008): Thanks to Chris May for the following step by step instructions on how to overcome this issue (edited for formatting, the original version is comment #8):

I have found some information about this.

Though it is possible at the time a script is saved to change the encoding to ascii it is tedious. Here is the process.

  1. Choose File\Save
  2. Choose the name and folder to save the file then look really closely at the right edge of the “Save” button for a tiny arrow
  3. Click that tiny Arrow and choose “Save with Encoding”
  4. From the Drop list select the encoding you want (the default encoding is “Unicode – Codepage 1200″, which means “UTF-16″). I have been using “US-ASCII – Codepage 20127″
  5. Hit OK and Save. Your files should now work just fine with Perforce, CVS, etc.

Additionally, Chris has voiced his feedback to the SQL team, I encourage everyone to go have a look and hopefully we can get a solution sooner rather than later… although the outlook is bleak.