Tuesday, 12 February 2013

Sloppiness is killing me


As a developer I'm reviewing or taking over codebases a lot. I had the luck to work on rockstar coders' masterpieces. I've learned so many. On the other hand I got horrible codes too. I have OCD, which makes the whole thing worse.


I believe that your work is like your arse. It has to be clean and tidy when there is a change that somebody will use it. Let me introduce my favorite superheroes. First one is TabMan:

function foo() {
$var =    'value';
       do_important_call();
        another_method();
  }


Probably it's the gravity or the wind - TabMan's only weakness I guess. Okay, before I go sarcastic I know it's separate editor setting - maybe. But this is important, not following tabbing conventions ruins the eye tracking of the core and separation scopes.

Next hero is SpaceMan:

function  ( $foo,$bar)
{
  $foo     = 'value';
  $foobar    = 3.14;
  if($foo=1 ) {
    create_object( array ( $foo. '_orig') );
  }
}


SpaceMan's biggest ability to put spaces anywhere. The only mystery is what are the rules here to place a whitespace.

Next extraordinary character is the NameMan:

class MyObject2 {

  public function myobject_action($a) {
    $this->lh = $A;
    $array = array($A);
    $return = $this->resultFoo_BAR();
    return $return;
  }

}


NameMan's skill to mystify variables, functions and classes is brilliant.

I guess these are the most representative examples. I have many other favorites, of course. Random new lines can be really disturbing. There is a dangerous habit where comments are like art in code. You can see it as documentation, warnings, just tags, markers of various things, such as end of a function or a code block.

These issues are really easy to handle. With a proper IDE it's even hard to make any of these untidy coding styles. There are standards out there for: Drupal, Pear, Wordpress, Symfony or GNU just some of them. If you haven't read any - it's high time to do so.

---

I guess I missed some alternative heroes, like GitCommitMessageMan, DBSchemaMan or CSSAbsoluteMan. What are your heroes?

Peter

2 comments:

  1. My favorite is CommentMan.

    //somedev1 - 6/7/02 Adding temporary tracking of Logic screen
    //somedev2 - 5/22/07 Temporary my ass

    See a nice collection here: http://deconectat.wordpress.com/2010/09/23/top-funny-source-code-comments/

    ReplyDelete
  2. Hi James, those collections are one of my favorite :) Thanks for completing the post ;)

    ReplyDelete