Coding Style

1.  Am I weird?

2.  Spacing

3.  Examples

4.  Final Thoughts

Weird

I always wonder if I’m just an awkward programmer. I totally understand that everyone has their own style and “mark” with programming, however, I’ve never really met someone who likes as much spacing as I do.  Every default/built-in formatter must be replaced or altered so that it works how I like it.  It’s not that their format is bad or not correct, you could really put everything on one line.  But it’s just not like a book.  Like a book, everything is structured, and such is code.  I’ve always loved books that offer chapters.  Eragon, Harry Potter, Game of Thrones, etc.  All three of these titles use chapters often.  I love it.  I can’t stand reading books that are more or less, compact with tons of information, hence why many academic books, I can’t stand.  I think my coding style relates to this.

Spacing

By spacing, I mean new lines, tons and tons of new lines.  My methods will knowingly be on this one tab mark.  I will not have else’s hanging near a curly brace, and their will be new lines between different types of packages, and different purposed variables.  And please, please please please, do not have a whole if statement, condition and execution, on one line.  But at the same time, I like long lines.  No 80 character limit, we aren’t in the 90’s anymore.  We have monitors that support three times that many characters now, so please don’t have your method arguments containing multiple lines.  It’s not comfortable to skip down like this, even with the spacing.  To bring back the book idea, one thought, per a line.  If I’m running a condition, that’s a line.  Then I pre-prompt the execution (Curly brace), on another line, then I give the execution, and to end that off, my closing (Another curly brace).

As My Math Professor Says, “I’ll start off with some examples” **Spoken with an English accent**

The simple statement:

 while(true) { System.out.println("Infinite"); } 

No!  Should be something like:

while(true)
{
     System.out.println("Infinite");
}

I understand this adds a lot of lines for something not needed.  But read it.  What is easier to comprehend?  If I was to add a comment explaining it, I just add it.  I don’t worry about to reference in the comment, I just put it above or on the side (Depending on size).

Another least favorite of mine:

 if(i==0) i+=10; 

Really?  I mean, I understand usually with a line like this, it’s hard to not understand what’s going on.  But it’s just awkward to me.  I’m sure you can guess what I’d rather see:

if(i==0)
{
    i+=10;
}

Finally

Enough of the ramble.  I’ll just leave off with, I like tabs. I don’t like spaces.  Not all editors handle erasing whitespace similarly.  Where-as, I delete a tab, guess what? It deletes that whole block, not that block, including a line or two above it  But alas, I can adapt.  I can also use Astyle (Really love this program) to switch between what a class/company wants, to what I want.  Painlessly simple too.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s