August Meme Monday – Crap Code

Categories: Meme Monday, News, Professional, SSC
Tags:
Comments: 3 Comments
Published on: August 1, 2011

Interesting topic this month posted by Thomas LaRock.  This month he has chosen “crap code” as the topic.  I think it is interesting because there really are so many different ways to take this.

Knowing that there are so many qualifications for crap code, I personally like that of readability.  I know everybody has their own interpretation on how code should be written and what is readable.  However, I have to say that soooo many styles out there are not very good.  The style is sooooooo hard to read and follow.  For me, it is a coding nightmare to see code that is poorly formatted or not formatted at all.

[codesyntax lang=”tsql”]

[/codesyntax]

That code is just flat out difficult for me to read.  SQL Server handles white space just fine so a little formatting doesn’t hurt anything.  Better yet, it very well could help improve the readability of your code to more people than just you.  Something like the following helps.

[codesyntax lang=”tsql”]

[/codesyntax]

Now, for simplicity sake, I also introduced something in both of these code samples that I don’t like too much either.  In both cases I use a “Select *”.  This is bad form!  One really should also denote each column that you want to be returned.  Not only is it good for readability, but it can be useful for the query optimizer and indexing purposes.

 

So what do you consider to be crap code?

3 Comments - Leave a comment
  1. Mark says:

    It bothers me when people use column names (or other user named elements) that happen to be commands or functions. I’ll admit it – I’ve been guilty of it myself, but I avoid it. “SELECT AVG from Mytable.” Noooo! Crap code.

  2. jonmcrawford says:

    Lack of documentation/comments. What the code does != what the code is supposed to/assumed to do.

Leave a comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">








Calendar
August 2011
M T W T F S S
« Jul   Sep »
1234567
891011121314
15161718192021
22232425262728
293031  
Content
SQLHelp

SQLHelp


Welcome , today is Tuesday, November 25, 2014