Indenting Brackets

This is one of my pet peeves. If you have never programmed, or read code you will probably not understand this. Anyways, here it goes.

Why on god’s green earth would anyone ever want to write code like this:


some_method() {

    // do stuff here

}

Now in this example the code is clean, but imagine 3 pages of nested statements indented like this. Especially if you fuck up the indenting at some point – which frequently happens when you copy and paste large chunks of code. Am I the only person who thinks that this type of indenting makes code more difficult to read? What is wrong with doing it like this?


some_method()
{

    // do stuff here

}

There. The brackets are aligned. I can visually see which blocks of code belong to each other even if your indentation is screwy. Tracing back to the beginning of method is now as easy as putting my finger on the screen and scrolling up till I hit an open bracket. Try doing that with the other style!

Every time someone gives me code which has the fucked up brackets, I tend to “correct it” as I read it, by hitting enter after every single open bracket I encounter. I know there are different styles and conventions but hell… I think placing open brackets on newline is a good coding practice which improves readability.

How does placing it on the same line improve anything? Seriously people. I’m very tolerant when it comes to coding practices, but come on!

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


%d bloggers like this: