Devlico.Us
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @devlicious

Derik Whittaker

Thoughts on Software Development, .Net, OOP, Design Patterns and all things cool



This code sucks....

How many times as developers have we taken a look at someone else's code and said 'This stuff sucks' or 'WTF where they thinking'?  I know I have said this plenty of time.  I also am pretty sure that others have said this about my code.  In fact I am KNOW I have said that about my own code when I have to go back at a later date and maintain it.

Why do we say this about other peoples code?
Why is that as professional developers we take a look at the code developed by the craftsmen before us and say, this code is crap?  I think I know the answer:

  • It really is crap
    Sometimes time code is written by either unskilled developers, or simply in a manner that goes against all rational thought.  Sadly I am sure this happens more often then we would like to believe, but it is true.

  • It follows no discernable patterns
    There is nothing harder then reading code that follows no pattern.  This type of code tends to make everyone (even the author) scratch their head in wonder. 

    The sad thing is that code that is without pattern, is worse (in my opinion) then crappy code that follows patterns.  At least crappy code that follows a pattern can be easy to fix/maintain.

  • We don't understand the context of the code, or thoughts of the developer
    Even the best code can be 'crap' if the next guy does not understand why it was written the way it was.  As professionals, we have to assume that the coders before us 'had a reason', or they would not have written what they wrote.

  • We are envious of the code, but are too ashamed to admit it
    This is the hardest for me to admit.  There are times where we as professionals run across good, clean, concise code that is 'great' by all measure of the word.  But it may be over my head, or it may be following a pattern that is foreign to you.

    When this happens, we tend to put up our defenses and start slinging the 'this is crap' phrase around.

Do we really mean it?
When we say mean and hateful things about other peoples code do we mean them?

  • Yes, we are mean spirited people
    Sometimes we do really mean it.  Maybe it is crap, but do we really have to start telling everyone it is crap?

  • No, we just think it is bad code
    Sometimes we say the code is crap, but we really don't mean it.  This tends to happen when the code does not fit our style, or if it is using patterns we don't like.  Just because the code is not to your liking, does not mean it is crap.

    Maybe when we run across code like this we should use it as a time to learn, as a time to expand our horizons, or (gasp) a time to rethink some of our likes/dislikes.

  • No, but it makes us feel better saying it.
    This one goes hand in hand with the one above (We are envious of the code, but are too ashamed to admit it).  It is only human nature to mock that in which we do not understand.  DON'T lets grow as developers, take the time to learn and improve our skills.

What can we do to prevent it?

  • Nothing, it is human nature.  Sorry :(

 

The bottom line is this.  As much as we would like to say that what we do is a science, it is not.  It is an art form, and we are artist.  Because of this, we tend to unfairly judge things in which we don't like or don't understand.

So the next time you run across some code that looks like crap, maybe it is, or maybe it is not.  But either way, just do what you have to do and move on.

Final words
When given lemons, make lemon-aid.  When given poop, make poop-aid.

Till next time,



Comments

Damien Guard said:

I think sometimes we believe the code is overcomplicated and could be much more elegant because we have limited knowledge of the problem it is addressing.

When you finally dig all the way through and understand the various nuances it needs to handle you may appreciate why the code isn't as elegant as you hoped.

[)amien

# December 11, 2007 2:49 AM

DotNetKicks.com said:

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# December 11, 2007 1:22 PM

Trumpi's blog said:

Software Parallels CTP - please don't all rush at once to get this. Otherwise we'll have a race

# December 12, 2007 5:16 PM

Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add

About Derik Whittaker

Derik is a .Net Developer/Architect specializing in WinForms working out the northern suburbs of Chicago. He is also believer and advocate for Agile development including SCRUM, TDD, CI, etc.

When Derik is not writing code he can be found spending time with his wife and young son, climbing on his bouldering wall, watching sports (mostly baseball), and generally vegging out. Check out Devlicio.us!

Our Sponsors

Proudly Partnered With


This Blog

Syndication

News