Report article RSS Feed Four steps to improve your code!

Posted by Herr_Alien on Sep 24th, 2009

This is especially valid when the code you're writting will be used/extended by others.Here's what you should do if your plan is to piss off your co-workers:

  • Do not document parameter values.  That will definitely cause grief among other developers. Imagine them debugging through the code, trying to figure out what did they do wrong. I mean when invoking one of your methods, one thing that the will do when that method fails is to ask themselves if, perhaps, the parameters they used on your method were wrong. Imagine their face turning red, then blue, then green, sweeping through all the colors of the rainbow when finding that if , or switch-case, or whatever hardcoded construct you placed there. YAY!
  • Hardcode naming rules for input/output file names. That's another good one. Place that string comparison/splitting/parsing for file names in the most hidden spot in the CPP code. Then, when the work mate uses your function, they'll never figure out why their parameter/config/input file is not loaded.
  • Do not write anything resembling documentation in the header files. Heck, if possible, also remove the name of the parameters. I mean if it doesn't make any use for the compiler, why bother?
  • Write multiple statements in one line. This comes really handy, and will allow you to see the entire function in one screen. Don't bother about making it easy for debugging, your code is so good there will be no debugging. So, remember, always do this:

               if(condition) return; // this is good!

        instead of:

              if(condition) // this is bad!
                  return;

And these steps will make you one of the most popular developers in your company!

Post a Comment
click to sign in

You are not logged in, your comment will be anonymous unless you join the community today (totally free - or sign in with your social account on the right) which we encourage all contributors to do.

2000 characters limit; HTML formatting and smileys are not supported - text only

Level
Avatar
Avatar
Offline Since
Oct 1, 2014
Country
Romania Romania
Gender
Male
Member Watch
Track this member
Blog
Browse
Blogs
Views
79 (1 today)
Report Abuse
Report article