Banging your head all day against a codebase that has been so badly polluted by incompetent developers can really take its toll. So here’s a list of things you can do to relieve the stress. In each case note who the culprit is so you can “name and shame” later:
- count the number of times the plonkers have put double negatives in the code. You know, things like
- if (! (something != somethingElse) ) { …
- hunt around for a) nested loops and b) nested loops that don’t sensibly exit when they should. You get extra brownie points if you can spot one in a critcal execution path.
- for(Idiot iDot : collectionOne){
- …
- for (Stoopid duh : collectionTwo){
- …
- }
- }
- // tada! look mum, I just wasted a whole load of time for no reason at all
- return somthingThatCouldHaveBeenFoundAgesAgo;
- Count the number of times you see the same 5 lines of code repeated in the same class. Extra points here for spotting this across sibling classes. Even more points if you spot a case where an implementation in the base class already exists so the subclass is overwriting the base class implementation with the exact same code. Gah!
- Count the number of times a method begins with the same two or more words. Like createSomethingUsingA() and createSomethingUsingAWellAlmostAllOfA(). Accessors don’t count.
- Look for classes that implement THE SAME METHODS as a generalised utility class, but make no reference at all to the utility class and the clever clogs who thought to put his code there.
- Count the number of //TODO comments scattered throughout the code. If you are really bored, use your SC system to work out how old the comment is. Make a note of its age.
- See how many recursive loops you can find in a class. Play a game with yourself and predict how many recursions it will take before the VM explodes with a StackOverflowError. Make a bet with a colleague and wait for the production defect ticket to roll in.
- Count the number of static classes and static methods in instantiated classes. Order a small trophy with the words “luddite of the century” engraved on the side, include the statics count and ceremoniously give it to the responsible colleague. If he/she is no longer there, have a posthumous ceremony in the Pub instead to drink away the pain they have caused you.
- See how many methods modify the content of an argument without making any comment or effort of any kind to indicate to the sucker following along behind that this method is going to mysteriously change the data on you without warning. Even better, see if you can find a method that returns a COMPLETELY DIFFERENT OBJECT TYPE while also modifying your argument on the sly.
- And to my favourite: Count the number of offences above commited by each member of your team. There will be certainly one, if not two, who are consistently rubbish. Go get them a large trophy with “Consistently Rubbish” on the side. Adorn it with all of his/her wrap sheet, for extra zing add the number of hours you have spent looking at and unravelling their cock ups. Present this trophy to the “winner” in front of his/her line manager.
OK, so you may be without a job after 10), but you will have had a certain satisfaction knowing that you have exposed a serious weakness in the team and that you had public display of your own saintly suffering.