Coding styles

Published on: 15.1.2014 22:06

..................................................................................................

If you don't know what a coding style means, you probably rarely work in a team.
It is simply a set of rules, by which all programmers in a team write their code, so they can read each others code easier.

 

One of the most used coding style is, how you write your variables and method/function names

1. CamelCase: ThisIsAVariableWithALongName

2. Underscore: this_is_a_variable_with_a_long_name

 

I think programmers choose variable naming convention based on which coding language they work in. C# developers, generally use camelcase, zend framework (PHP) uses underscore etc. I personally am using a camelCase. But be careful, when you use camelCase with naming filenames. It can get you in troubles, if you're not careful. Especially when server is on linux (filenames caseSensitive) and you're working in windows (filenames caseInsensitve).

 

Next quite visible is indent.

Every code in a loop, or in condition, or child tag should be indented. But for how much and with what, space or tab?

For example here is an indent with 4 spaces:

 

function parentFunction {

    thisIsIndentedCode();

}

 

Don't you just love it when you get a file, with different indent than what you're using. :)

I personally use tab with the size of 2 spaces. It's faster to press on a tab button than space twice, or even more times, if you want larger indent. And For me the size of 2 spaces is more than enough in all coding languages.

 

So what are you using and why? Comment below.

 

+ Comments (0)

Write a new comment: