Does Coding Style Matter?
theodp writes "Over at Smashing Magazine, Nicholas C. Zakas makes the case for Why Coding Style Matters. 'Coding style guides are an important part of writing code as a professional,' Zakas concludes. 'Whether you're writing JavaScript or CSS or any other language, deciding how your code should look is an important part of overall code quality. If you don't already have a style guide for your team or project, it's worth the time to start one.' So, how are coding style guidelines working (or not) in your world?"
... and it makes version control diffs shorter and to the point.
Tabs indent, spaces align. Your code should look equally good no matter whether tabstop is three characters or eight.
I use tabs because anyone can set the width to whatever they like (2, 4 or 8 spaces usually).
There still exists a lot of tools that assume tab stops are 8, without the ability to change them. Some people use those tools by choice, some people use those tools by mandate.
The best article that I've ever read on coding style is Style is Substance by Ken Arnold.
I won't repeat what he has to say here, because he explains it better than I could. But I wish that more programming languages would follow what he is advocating, because we waste way too much time arguing about braces and tabs.
Just use Artistic Style for C and its derivatives C++, C#, and Java. I usually set it for "--style=ansi", but that's a project preference. External code is run through Artistic Style before use. This way, everyone knows the indentation is consistent.
For Python, of course, there are few formatting options, so this isn't an issue. Dreamweaver will indent HTML. Javascript remains a problem.
Yes, most editors allow you to change, but I also use command line tools like grep, less, or diff, and they just send the tabs to the terminal which interprets them the standard way with a spacing of 8. Sure, I can set my terminal to change the tab width, but if I then grep some other sources, such as the Linux kernel tree, in the same terminal window, it gets messed up again. The solution is obvious and simple. Just leave the tab width at 8, and everything works fine, even it uses a mix of tabs and spaces for formatting.
My does:
My don'ts list is getting shorter and shorter. Most programmers have reasons why they produce the code the way they do. Lack of experience should be met with understanding and appreciation for improvements.
I hadn't the slightest objection to his spending his time planning massacres for the bourgeoisie... (P.G. Wodehouse)
one of these guys is using Comic Sans as his coding font, as he's dyslexic and it helps him
Has he looked into fonts designed to help dyslexics, like Gill Dyslexic and Open-Dyslexic?
Dilbert RSS feed
no, it's you who broke the formatting by mixing whitespace characters.
and you don't want to type "| expand -t4", so you're going to make a mess of the commit log, make diff a mess, and force everyone else to run everything through indent.
It's sloppy and inconsistent.. and you're making it harder for everyone else on your team because of your laziness.