2/11/2014 7:51:45 PM

Aside from what language you code with, one of the most highly debateable aspects of coding is coding styles. There are many different and everybody thinks theres is correct, including me. But I don't want to simply state what mine are, I want to give you a quick reason behind most of my style choices.

To understand why I do what I do, we must admit one thing. Coding styles is all about human readablility and convenience. The compiler doesn't care (maybe with VB and some others but for the most part it doesn't care). If you want to put all of your code on 1 line, the compiler will be happy. If you hate indenting, the compiler doesn't care.

So why do it at all? We do it so that our lives are easier. We visually process information and "proper" formatting allows us to process information faster. That is really all coding styles is about. And keeping constant styles across multiple projects and multiple team members ensures that we can all (hopefully) process the information quicker. So the reasoning behind most of the coding style choices is all about the fastest way to process information. And so I begin.

Braces

Braces in code tend to be one of the most highly debated of all coding styles. With that being said, there is only one logical style.

public void DoSomething() { //do something }

As you can see, I put braces on their own line. Why? Because it is the easiest and quickest way to visually process the information. Whether I go from the top brace or the bottom brace, the braces are always aligned. If I were to put the braces at the end of the statement, my eyes would not be able to quickly determine the matching brace (especially from the bottom).