Derik Whittaker

Syndication

News


Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
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,


Posted 12-10-2007 8:54 PM by Derik Whittaker
Filed under: , ,

[Advertisement]

Comments

PartialClass wrote re: This code sucks....
on 12-11-2007 2:12 AM

lol... very natural post derik

Damien Guard wrote re: This code sucks....
on 12-11-2007 2:49 AM

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

DotNetKicks.com wrote This code sucks....
on 12-11-2007 1:22 PM

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

Trumpi's blog wrote Our daily link (2007/12/12)
on 12-12-2007 5:16 PM

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

Phentermine. wrote Phentermine.
on 05-30-2009 9:57 PM

Phentermine. Buy phentermine online. Phentermine cheap. Phentermine overnight. Phentermine no prescription. Cheapest phentermine. Phentermine cod.

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Subscribe
Google Reader or Homepage

del.icio.us CodeBetter.com Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl CodeBetter.com Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of Devlicio.us
Red-Gate Tools For SQL and .NET

NDepend

SlickEdit
 
SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
LiteAccounting.Com
DevExpress
Fixx
NHibernate Profiler
Unfuddle
Balsamiq Mockups
Scrumy
JetBrains - ReSharper
Umbraco
NServiceBus
RavenDb
Web Sequence Diagrams
Ducksboard<-- NEW Friend!

 



Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers

 

Community Server (Commercial Edition)