Atkelar (atkelar) wrote,

WTF coding #6 - "open source"...

This post is not my typical rant about the concept of open source but rather a note about how funny it can be to read things that other people write... I don't dare say "code" because of the level of stupidity involved sometimes.

Two fragments of C# code I came across yesterday are currently on the top of my list. Here's one (I changed the names of the variables to protect the guilty party):

if (xxx != null
     && (false
         || (true
             && string.Equals(xxx.yyy, 

I suspect I know how this came about... there may have been other conditions that got removed and instead of fixing the nested parentheses, they replaced them with constants. Still, that's how you make your code hard to read, hard to maintain and hard to understand. And hard doesn't equal "solid" ;)

And how about this conditional branch a few lines onward?

if (xxx == null)
    return yyy;
return yyy;

I had a friend in my school wayyyy back when DOS and Turbo Pascal was the thing who did something like that to "make sure it gets done the right way"... as if the computer would decide to randomly skip a statement just because it is not written in double.

Bottom line: if changes to your code render parts of it useless - especially when they are THAT obvious - remove them! It will save you headaches in the long run!
Tags: coding, software development, wtf

  • YouTube... or rather Google.

    Well, the most recent update in the TOS of YouTube did cause quite a stir, to the point that there are now petitions going around. And here's where I…

  • WTF: Graphics "design"

    This time: PDF and "graphics artists". Don't get me wrong, I do respect the amount of work that go into graphical artwork and design, not a problem…

  • WTF - Fitness Tracker

    Well... after resisting the urge for the longest time I finally caved and got myself one of these nifty fitness tracker wristbands. I stood in the…

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded