How Big is Your Tab?

This is just a mini-rant, which is why it’s not being published on the usual Saturday.
Question: What’s your preferred tab width? 2 spaces or 4?
There are a lot of people out there who prefer a 4-space tab. Here’s an example:
public class MyClass {
    public void function(int param) {
        if(condition) {
            System.out.println("This program has 4-space tabs");
        }
    }
}
But a lot of people out there say that this is too big of a tab; you lose too much space after a few tabs in. I don’t think it’s too big of a deal, especially since you should probably refactor the code if it’s getting too deep, but I still don’t like how big it is either.
How Big is Your Tab

On the other side of the argument are those that fight for 2-space tabs. Here’s the same example with 2 spaces instead of 4:
public class MyClass {
  public void function(int param) {
    if(condition) {
      System.out.println("This program has 2-space tabs");
    }
  }
}
Those that are against 2-space give the reason that the spacing is too small, making it difficult to tell what level some things are at. I agree with this argument, too.

Goldilocks Solution

So there’s this big divide out there over the solution that many say is too big and the solution that many say is too small. If only there was a middle ground!
Wait… BETWEEN 2 and 4? There’s a number there? Oh yeah! 3!
Seriously, why hasn’t the world just settled on 3? Here’s an example:
public class MyClass {
   public void function(int param) {
      if(condition) {
         System.out.println("This program has 3-space tabs");
      }
   }
}
Hmm… Not only does the number 3 seem like a good compromise simply because it’s perfectly between the two other numbers that are argued over, but it actually seems to address the issues of both numbers, at least to a satisfactory degree.
Before I even knew there was a debate over this, when I was still in college, I was playing around with the IDE settings and found the one for tab size. It was defaulted at 4, and I had often thought that is was a little big, so I changed it to 2. Well, that created the readability problem mentioned above, so I set it to 3, was very satisfied, and now I’ve been using it ever since.
I still don’t get why this is debated, considering I solved the “problem” before I even knew better.

Fin

Anyway, this is the end of my rant. If you agree, please spread the word. If you disagree, please don’t start a debate in my comments. If you really want, you can put your preference in the comments, but I seriously don’t need arguments in my comment section.

NOTE

You’ll maybe have noticed that I keep the opening curly braces on the same line as the method signature/if conditional line. This is not my preferred way of doing it. In fact, I hate it. I prefer on the next line, or with no braces at all (yay Python!).
But this is more “standard”, so it’s probably preferred by most of my readers. In this, I cater to the readers, especially since it helps to reduce the number of lines of code on the blog, which I usually consider a plus; scrolling sucks.
How Big is Your Tab? How Big is Your Tab? Reviewed by Anonymous J on 05:35:00 Rating: 5
Powered by Blogger.