KBD

Keith Devens .com

Friday, May 16, 2008 Flag waving
Although at the beginning the paradigm was worth consideration, now the entire effort in the primeval soup paradigm is self-... – Hubert P. Yockey (Information Theory and Molecular Biology, p336)

Tag: Coding Style

Parents:

Daily link icon Saturday, March 18, 2006

  1. My tabs vs spaces wiki page is on Mefi even though I have essentially no content on it Smiley Figure I'll go and read some of the other posts linked eventually.

       (0) Tags: [Coding Style]

Daily link icon Tuesday, February 7, 2006

More on tabs vs. spaces

So, at work I've just been using the default settings on Visual Studio to determine my brace style and indent style. To my surprise I've found the spaces vs. tabs issue far more important than having my code look "double spaced" with braces on their own lines. For one, ASP.NET doesn't get you very dense or detailed code anyway, so it doesn't matter as much that there are some extra blank lines spacing out the code. The thing that's annoyed me about having leading spaces instead of tabs is that it gets real old real fast having to hit the backspace key four times the number of times I'd have to hit it were I using tabs. Say I hit the tab key an extra time by accident... that's four times I have to hit the backspace key. In fact, that's an extra argument for using tabs I hadn't considered before. A one-to-one correspondence not only between the number of times you hit 'tab' and the number of characters put in the file, but between the number of times you hit 'tab' and the number of times you have to hit 'backspace' to remove that "tab".

Daily link icon Tuesday, October 18, 2005

Code style

Was just reminded of something (code taken from here (linked earlier)). Compared to the following:

public class Point
{
    private int x, y;
    
    public Point()
    {
        x = 0;
        y = 0;
    }

    public int X
    {
        get
        {
            return x;
        }
        set
        {
            x = value;
        }
    }

    public int Y
    {
        get
        {
            return y;
        }
        set
        {
            y = value;
        }
    }
}

Something like the following:

public class Point{
    private int x, y;
    
    public Point(){
        x = 0;
        y = 0;
    }

    public int X{
        get{
            return x;
        }
        set{
            x = value;
        }
    }
    
    public int Y{
        get{
            return y;
        }
        set{
            y = value;
        }
    }
}

or particularly the following:

public class Point{
    private int x, y;
    
    public Point(){
        x = 0;
        y = 0;
    }

    public int X{
        get{ return x; }
        set{ x = value; }
    }
    
    public int Y{
        get{ return y; }
        set{ y = value; }
    }
}

seems so clearly superior to me that I don't see what there is to debate. It's beyond me how anyone would like to read the first version, which is the exact same code as the final version but with 16 extra lines of nothing to wade through. It's almost twice as many lines as the final version.


While I'm here I might as well harp on tabs vs spaces. I'll never understand why some people prefer to only use spaces instead of tabs. Tab means "one level of indentation". Furthermore, some people like to use two spaces to indent their code. That's perfectly fine, but use tabs so I don't have to care about how you like to view your code.

Daily link icon Sunday, July 17, 2005

  1. Damian Conway: Ten Essential Development Practices. The part on command line handling is a particularly good reference, and I want to go back and read his section on exceptions.

    Also, I think the part on writing "paragraphs" of code is exactly how it should be done. Some people I work with put a space practically between every line. By doing that you lose the semantic utility of the blank line.

       (0) Tags: [Coding Style, Programming]
May 2008
SunMonTueWedThuFriSat
 123
45678910
11121314151617
18192021222324
25262728293031



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 1 posts

Recent comments XML

"IMDB for music"

IMDB for Music? It looks to be a​couple of years old...​http://MusicTell.co...

Ken Empie: May 14, 9:57pm

Generated in about 0.121s.

(Used 10 db queries)