Tuesday, July 10, 2018

Sloppiness is killing me

Sloppiness is killing me



As a developer Im reviewing or taking over codebases a lot. I had the luck to work on rockstar coders masterpieces. Ive 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 its the gravity or the wind - TabMans only weakness I guess. Okay, before I go sarcastic I know its 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) );
}
}


SpaceMans 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;
}

}


NameMans 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 its 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 havent read any - its high time to do so.

---

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

Peter

go to link download