I’ve been web programming for about 4 years now. Primarily I’m a PHP programmer (self-taught) with some Javasript thrown in here and there and Actionscript only when I absolutely have to. Programming is a strange animal. I tell my wife often that I really love my job, because I do, but to listen to me sitting at my computer on some days I’m sure an outsider would think that this is only something I do because I have to. The frustration comes regularly, though not as often as when I first started programming, but it does still come. I sometimes feel like my real job is fixing two kinds of problems: ones that others create and ones that I create.
Over the years I have formulated some rules for myself that have become invaluable to me when the problems arise. The browser might crash, the screen may go blank, the code snippet I’ve written is not doing what it is supposed to, I’m getting error messages that tell me any number of things I’ve done wrong. What to do? How does one approach a problem? Here are my rules for dealing with problem code in a very particular order:
- Your code is wrong. This is always the first thing you should keep in mind. Don’t ever initially fall into the trap of thinking something must be wrong with the machine processing your perfect code. This will kill you and waste many of your hours.
- If you are absolutely positive that your code is correct: Your code is wrong. Yes, that’s right. Even when you are sure your code is correct . . . it’s not. Trust me. Again, once you come to the conclusion that your code is fine and it must be the damn computer’s fault you have need to abandon all hope. Trust me.
- If you have progressed through rules 1 and 2 and know for sure it must be the computer’s fault remember this: Your code is wrong. Seriously. It is. It is bad code and you wrote it and you’re responsible for it and it’s all your fault.
- Your code is wrong. It is, I’m telling you it is and it is. Don’t forget this. I know you’re the next Einstein or the next Bill Gates or the next Trinity, but I’m telling you: YOUR . . . CODE . . . IS . . . WRONG.
- So now you’ve made it to rule 5. If you haven’t solved the problem by now, you’re pretty frustrated. You’ve probably left your desk several times, cursed enough to warrant several confessions. You’ve looked for typos, logical errors, syntax errors, you’ve searched the internet, got sidetracked in some forum discussing barbecued pizza and you have every right to consider that the problem may not be yours, that it might actually be something that is not your fault, that some evil programmer who could program you into oblivion has made a mistake and you have discovered it. Nope. Your code is wrong. Mark it down. Carve it into your desk. Build a website around it. For the sake of simplicity and ultimately your sanity always remember: your code is wrong. Trust me. It is.