![]() |
How do you write your code?
Greetings!
I recently came across this Wikipedia article on indent styles, and thought it could be fun to see how the member of this community writes their code. I would like to point out that I did not pick the style I liked the most and started writing that way, after reading the article. I found the style most equal to the way I write my code. It turned out to be a mixture of Allman style and my own. Example: PHP Code:
Let me know if the thread title could be better. Yours, Runar |
I generally stick to Allman/BSD style, easiest to read IMO.
|
Based on the code you provided I would write it like this:
PHP Code:
|
One thing I've began to do that most do not is placing the constant to the left and the variable to the right. For example
PHP Code:
It looks awkward at first but becomes very useful once you get used to it. |
Something like this:
PHP Code:
|
I prefer to use a space after things like
if, before the opening parenthesis, and to keep curly brace pairs at the same indent level (Allman style). E.g.:PHP Code:
|
Mine is like this
PHP Code:
|
PHP Code:
|
Just like Salathe
PHP Code:
|
PHP Code:
|
Allman/BSD for me too.
I also like to line up things like so: PHP Code:
|
php Code:
javascript Code:
css Code:
css Code:
|
I am the same as Salathe and a few others in this thread. However, touching on Village Idiot's point, I much prefer my variables to the left of the invariables.
As we typically read left from right, I like to see the variables and/or constants that are involved in the conditional immediately, instead of seeing the invariable, and then seeing what it's being checked against. As Zend Framework is built by many programmers, I've noticed they use both ways in their framework code. I never thought of it as being a way to prevent accidental typos. It's always nice to have a new perspective on things :-) ! |
@Tanax I've seen this CSS style used by a few people and I really like it, what do you think?
css Code:
|
I actually do the same, adamdecaf. It has worked pretty good for me so far.
|
Quote:
|
Quote:
|
that css-code-style is new to me to. Might give it a try...
|
@adamdecaf
I do something similar. instead of: PHP Code:
PHP Code:
Same thing when I am programming I would do it in the format of PHP Code:
|
@CoryMathews
Your style seems great, but it seems to crammed for me. I have also learned to sort the CSS by alpha-numeric, it really speeds up the searching process. Also you can compress the final CSS with this tool: Online CSS Compressor - CSSDrive.com, it offers a wealth of options to suit your compression needs. One of my friends likes to put his CSS in the single line format, I guess its personal preference as to what style is used. |
| All times are GMT. The time now is 08:13 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0