Code You Should Not Be Writing – Part 3

Well, this is part 3 already. I hope you’ve enjoyed and appreciated the last 2 part and understand my pain. Well, here’s something that doesn’t seem all too convoluted, but could have been achieved with just 1 line of code. By the way, just for those who don’t know, there isn’t really anything syntactically wrong with any of these code.

for (int i = 0; i < 24; i++)
{
    string strIndex;
    if (i < 10)
    {
        strIndex = "0" + i.ToString();
    }
    else
    {
        strIndex = i.ToString();
    }
    // ... do more stuff with strIndex
}

It’s slightly tougher to understand why this is bad code for those inexperienced. For those you understand why you should not write this code, good for you! You’ve got some developer sense in you. Till the next part, I hope you enjoy this code. Learn not to write like that, please.

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • RSS
  • Twitter

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

3 Comments »

 
 

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CommentLuv Enabled