Dear Idiotic Developer:
OPC is our internal slang for Other Peoples Code. I’ve talked about this before but just in case you’ve never been here before, OPC projects are always the most dangerous kind of projects to work on. They can quickly become a rats nest and cause no end of grief mainly because you have to figure out what the original programmer (or programmers) was thinking. Because it’s a Friday afternoon and I’ve been up to my elbows in digging through your OPC project all week here is my list of complaints:
- Poor variable names: Variables such at ‘tmpd’ and ”bDbDl” don’t tell me anything. Long variable names aren’t going to kill you and using Real Studio’s autocomplete will (usually) make this a non-issue.
- Three Letter Acronym (TLA) Variable names: Stop being lazy and use some real words. Obviously you didn’t expect someone else to read your code in five years. If I ever find you I promise I will mock you. I hope you are doing a better job of naming variables in your new job than your last one!
- Poor method names: Methods named “SelAcc” and “DoWork” don’t give me any type of clue on what it does – especially when you have no comments in your code.
- Nested If-Then Blocks from Death: There are times you need to do this but it’s been my experience if you’ve got more than 2 or 3 at any given time your method is too long and should be broken up into smaller methods. Keep it simple. Complexity kills.
- Multiple nested loops from death: See nested if-then blocks from death above.
- Long methods: This kinds of goes with the previous two. If your methods scroll and scroll and scroll you have a problem. If you had a problem in that method (i.e. it throws an exception) good luck finding the problem. Break it up into smaller chunks of code. Perhaps you can take the 100 lines of code you have the first part of your IF statement and break that out? Just sayin’.
- Controls using the default names: Really, you expect me to figure out the difference between TextField1 and TextField11 by making me look at the UI? Next time, please use a name that will mean something to you in code.
- Controls using generic names: On the flip side you used a name different than the default one. Good for you. Perhaps next time you can use something other than ‘s’ for its name because it took me a while to figure out it was damn text field rather than just a plain string.
- Constant names versus property names: Quite ingenious the way you used the same constant name as a property name so that the IDE doesn’t help me in autocomplete. Thanks. That’s ones special.
- Stop trying to be fancy: I get it. You went to whiz bang college and learned some cool programming tricks and techniques and you’re pretty smart. Remember, you’re writing for your boss/client/person who signs your paycheck so don’t forget that you’ll eventually move on/get fired/hit by a bus. Be nice to the poor bastard that has to learn your code after you. Assume they do not have your skill set.
- No comments/documentation. Of course given all the previous bullet points this one isn’t surprising. Would it have killed you to put a sentence – ONE SINGLE &*^!@% SENTENCE – describing what a method does? If you hadn’t done all of the above items too that’s all it would have taken but instead you have ZERO comments in 10,000+ lines of code.
But, I must say thanks for reminding me why I don’t like working on OPC projects. You’ve taught me that just saying “no” in future projects will make my life easier and less complicated. My wife, kids, and dog will like me better if I don’t take another OPC project.
I think if I had any advice for programmers just starting out. Spend six months fixing Other Peoples Code (OPC) and see what drives you absolutely bonkers. Then, and only then, can you start writing your own code. You’ll hate it but it will give you some very valuable experience early in your career, on the things not to do. Being kind to the developers that come after you is just as important and by doing this you’ll know.
Ultimately I’m a lazy programmer. Not that I don’t do the work I just don’t want to work that hard at figuring out old code. If you name your variables and methods properly and consistently, keep your methods short, and if you write minimal comments it’s not that hard to figure it all out later. Having to guess at someone else intent makes my head hurt.
So dear readers what OPC foibles drive you crazy?