Page 1 of 4
Coding standards... and me.
Posted: Fri Aug 10, 2007 7:53 am
by s.dot
I forget which topic it was in where someone told me that adapting to standards is a sign of a mature programmer. So, I'm trying with the zend coding standards. I got the spacing down. And the parenthesis. Which I don't like, but I can deal with it.
Code: Select all
if (foo) {
//do this
}
function bar($more)
{
//do that
}
I can even deal with the variable naming (which I also don't like).
All of the rest I pretty much did already, making it easy to comply.
However, the one I refuse to change (maybe it's my immaturity) is using 4 spaces instead of tabs. I don't think I will ever change that. Tab is just way easier, in my opinion. And I've been used to it since back when I started writing HTML.
Is that that much of a big deal? I mean most editors come with a function that converts tabs to spaces and vice versa.
I don't want to start the tabs vs spaces debate though.
My point of this topic is do you conform to coding standards? If so, which? Was it hard to get into practice of using the standards? Are there any (like me) that you just refuse to use?
Posted: Fri Aug 10, 2007 8:12 am
by shiznatix
It seams that everyone has their own standards which are so simmilar but so different too. The ones I go with are:
Code: Select all
if (foo)
{
//do this
}
function foo()
{
//do that
}
$this_name_goes_here = foobar();
And yes, I use a tab instead of spaces. I used to be the other way around and would fight to the death about it but I dunno, it just seams easier to use tabs now. You can view my tabs in as many spaces as you want so no problems.
Posted: Fri Aug 10, 2007 8:17 am
by VladSun
The same as @shiznatix.
About the variable naming - I feel pretty comfortable with both of suggested.
Posted: Fri Aug 10, 2007 8:25 am
by s.dot
In my opinion, $variable_name_here is so much "prettier", easy to read, and less prone to case errors.
Re: Coding standards... and me.
Posted: Fri Aug 10, 2007 9:36 am
by The Phoenix
scottayy wrote:
However, the one I refuse to change (maybe it's my immaturity) is using 4 spaces instead of tabs. I don't think I will ever change that. Tab is just way easier, in my opinion. And I've been used to it since back when I started writing HTML.
Is that that much of a big deal? I mean most editors come with a function that converts tabs to spaces and vice versa.
I don't want to start the tabs vs spaces debate though.
My point of this topic is do you conform to coding standards? If so, which? Was it hard to get into practice of using the standards? Are there any (like me) that you just refuse to use?
Definitely not starting the debate, or continuing it, but just wanted to point out the logic that led me to a different conclusion.
The tools in use: Putty on Windows, Firefox viewing the websvn on sourceforge, and nano on linux as the text editor.
Copy and paste from firefox, into nano via putty. Tabs are pasted as spaces. Now do a svn diff. Guess what? They are
different than the code you are viewing - resulting in an incorrect diff.
It makes it impossible to use that set of tools. Further, nano doesn't offer a way to view tabs as spaces as far as I know.
Tabs have plenty going for them, but cut-n-paste across multiple platforms isn't one of them. Tabs is good for compatibility between different coding styles, spaces is good when you need the code to be consistent
no matter what.
So, I went with spaces. There is almost never a time when a piece of software cannot consistently display four spaces.

Posted: Fri Aug 10, 2007 9:47 am
by TheMoose
The thing I like about Editplus is that I can set it so that whenever I tab, it uses 4 spaces instead of a tab, thus constraining to a standard, but keeping the ease of use of a single keystroke versus 4 keystrokes.
Posted: Fri Aug 10, 2007 10:26 am
by RobertGonzalez
Just about any editor wort its salt nowadays can spacify tabs (and vice versa). I am a tab man myself, except in one editor, which I use to write code for the forums (posting in the forums) because tabs in the Syntax Highlighter are way bigger than four spaces would be.
Posted: Fri Aug 10, 2007 10:35 am
by s.dot
Everah wrote:Just about any editor wort its salt nowadays can spacify tabs (and vice versa). I am a tab man myself, except in one editor, which I use to write code for the forums (posting in the forums) because tabs in the Syntax Highlighter are way bigger than four spaces would be.
I counted them once.

Tabs are 8 spaces on here (or the geshi mod... whatever you guys are using).
Posted: Fri Aug 10, 2007 10:40 am
by RobertGonzalez
Code: Select all
<?php
if ($spaces) {
echo 'These are spaces.';
} elseif ($tabs) {
echo 'These are tabs.';
}
?>
Posted: Fri Aug 10, 2007 11:00 am
by The Phoenix
Everah wrote:Just about any editor wort its salt nowadays can spacify tabs (and vice versa).
Turns out I was wrong - nano does support tabs->spaces. Nevertheless, the end result that gets committed (ie, the coding standard) for me has to remain spaces so I don't cause different diffs based on a tab v. a space.
Posted: Fri Aug 10, 2007 1:48 pm
by superdezign
I like tabs, but the editor I use (PHP Designer 2007) makes it so that I can treat spaces like tabs when traversing the document, so whether it's spaces or tabs, I don't notice the different unless I use the mouse.
Posted: Fri Aug 10, 2007 2:05 pm
by AKA Panama Jack
This is by far the BEST way to enter functions because it is much easier to visually match beginning and ending brackets.
Also, using tabs is also better than using spaces.
Why?
Because every file I have seen with tabs the person using them uses something different and they tend to mess things up. You have a programmer use 2 spaces for tabs and other uses 4 spaces for tabs. Yet another uses 3 spaces. And these same people who use tabs tend to screw up on the tabbing while editing their code. The person using 4 spaces sometimes inserts code at a 3 space point making everything unaligned.
I end up having to use search and replace to convert 2/3/4 space tabs to single tabs. That's easy but then I have to go back and remove all of their errors where they use extra spaces and BROKE their tab sequence.

Sloppy programming.
Yes, I know I am anal about formatting but it makes things so much easier to read if you get it right the first time.
Posted: Fri Aug 10, 2007 2:14 pm
by Benjamin
AKA Panama Jack wrote:Also, using tabs is also better than using spaces.
Tabs are the work of the Devil. If I was god I would abolish them into the depths of nothingness. They are useless placeholders destined to be replaced with spaces.
Posted: Fri Aug 10, 2007 2:14 pm
by AKA Panama Jack
The Phoenix wrote:Everah wrote:Just about any editor wort its salt nowadays can spacify tabs (and vice versa).
Turns out I was wrong - nano does support tabs->spaces. Nevertheless, the end result that gets committed (ie, the coding standard) for me has to remain spaces so I don't cause different diffs based on a tab v. a space.
Any Diff programm worth it's salt will basically ignore leading spaces and tabs that are outside quotes when comparing file code. If it doesn't then that DIFF program has a really bad problem. I have one called Free Diff that only compares actual code differences which is what a Diff program should do.
Posted: Fri Aug 10, 2007 2:15 pm
by Benjamin
But the files are different. They should show as different.