Click to See Complete Forum and Search --> : Spaces instead of tabs.


[e]r!k
10-04-2003, 07:32 PM
I'm using spaces instead of tabs since tabs are not the same in all programs. What do you think of this? Maybe you're doing the same?

Moonglobe
10-04-2003, 07:47 PM
for the second time today:

tabs suck.


my current style is like this:

if ($condition)
{
//1 brace per line, 4 space indent per level
}

jebster
10-04-2003, 09:32 PM
Originally posted by Moonglobe
for the second time today:

tabs suck.


my current style is like this:

if ($condition)
{
//1 brace per line, 4 space indent per level
}

I only do 2 spaces cause when I used 4 the code didn't like fitting in the screen always! :)

drawmack
10-04-2003, 10:09 PM
the coding standard that I use recommends spaces instead of tabs because tabs vary from program to program. For number of spaces it's a bit squishing saying should be 3 or 4 but must be consistent once a number is choosen.

Weedpacket
10-05-2003, 12:42 AM
The style I've tended to settle on is to use tabs for primary indenting only, and spaces for all other - er, spacing.

function_foo()
{
$oink_=_bar();
for($i=0;_$i<10;_$i++)
{
$baz____=_'This';___________//_Baz_is_that
$wibble_=_'Something_Else';_//_While_Wibble_is_something_else.
switch($oink[$i])
{
case_1:
blink();
break;
case_2:
barf();
break;
case_3:
boggle();
break;
default:
crash_and_burn();
}
}
$smoo_=_array_pop($oink);
echo_($smoo=='whatever')
_____?_"Smoo_is_whatever"
_____:_"Smoo_isn't.";
}

(Where I've used '_' instead of space so's you can tell them apart from
tabs without having to cut-and-paste it all yourself).

If I was writing more densely (as I tend to do), I'd gobble a line or so by going

function_foo()
{ $oink_=_bar();
for($i=0;_$i<10;_$i++)
{ $baz____=_'This';___________//_Baz_is_that

Tab damage should only throw off formatting in the second case, and even then only if tabs are one character wide....

laserlight
10-05-2003, 01:14 AM
Excluding any holy war on where exactly braces should be placed, I tend to use Weedpacket's version.

I usually use 4 space indents though, since 8 seems rather extreme to me, even if it is more "traditional".
2 doesnt quite give the visual differentiation of indent levels.

bad76
10-06-2003, 04:21 AM
Originally posted by laserlight
Excluding any holy war on where exactly braces should be placed, I tend to use Weedpacket's version.


Too late warning :), in the forum there is already any thread (http://www.phpbuilder.com/board/showthread.php?s=&threadid=10234388) about this...



I agree with weedpacket too, but i'm used to not put blank in the code... ($baz='This';...)

dotwebbie
10-06-2003, 01:39 PM
Hrm. I'm probably going to get pummeled, but I like to use the phpBB Coding Standards.

http://area51.phpbb.com/docs/guide-standards.html

I'm currently using them for the Site Control project (not to be confused with SiteControl :p). There are some things in the standards docs that I disagree with, but for the most part, it makes code much easier to read and for someone else to go through and see what is happening.

pyro
10-06-2003, 02:09 PM
I do it the same way that Weedpacket, or depending on what laserlight ment about the braces, perhaps her way...

stolzyboy
10-06-2003, 02:13 PM
Originally posted by pyro
I do it the same way that Weedpacket, or depending on what laserlight ment about the braces, perhaps her way...

me too...


for ($i = 0; $i < $outer_size; $i++)
{
for ($j = 0; $j < $inner_size; $j++)
{
foo($i, $j);
}
}

pyro
10-06-2003, 02:31 PM
I'd code that as such:

for ($i=0; $i<$outer_size; $i++) {
for ($j=0; $j<$inner_size; $j++) {
foo($i, $j);
}
}

stolzyboy
10-06-2003, 03:42 PM
Originally posted by pyro
I'd code that as such:

for ($i=0; $i<$outer_size; $i++) {
for ($j=0; $j<$inner_size; $j++) {
foo($i, $j);
}
}

oops, the me too was supposed to be for dotwebbie

i like them so you can look up and down and see them... not right after the condition

pyro
10-06-2003, 09:12 PM
That's how I used to do it, but then I fell under the influence of a Java programmer... :D

Moonglobe
10-06-2003, 10:52 PM
Originally posted by dotwebbie
Hrm. I'm probably going to get pummeled, but I like to use the phpBB Coding Standards.

http://area51.phpbb.com/docs/guide-standards.html

I'm currently using them for the Site Control project (not to be confused with SiteControl :p). There are some things in the standards docs that I disagree with, but for the most part, it makes code much easier to read and for someone else to go through and see what is happening.
I agree with everything in that except for tabs, and the only thing i do wrong is the use of the ternary operator for REALLY complex things. So that's why i could read the phpBB source so easily....

planetsim
10-06-2003, 11:40 PM
i use to be a "tab" er but i like to have only 2spaces.

But i guess it comes down to personal preference and if your working in a team the coding standard.

LordShryku
10-07-2003, 03:27 AM
I use tabs. I like large glaring indents. Flame away....

Weedpacket
10-07-2003, 04:17 AM
I've spooked the unwary with

for ($i=0; $i<$outer_size; $i++)
{ for ($j=0; $j<$inner_size; $j++)
{ foo($i, $j);
} }

Not that I'm recommending such behaviour.

dotwebbie
10-07-2003, 09:17 AM
Originally posted by Weedpacket
I've spooked the unwary with

for ($i=0; $i<$outer_size; $i++)
{ for ($j=0; $j<$inner_size; $j++)
{ foo($i, $j);
} }
eval()! :D
Not that I'm recommending such behaviour. I hope not. :p

laserlight
10-07-2003, 09:42 AM
looks like an optical illusion to me....

laserlight
10-07-2003, 09:55 AM
I think I've found a discrepancy in phpbb's coding guidelines:

Use spaces between tokens

/* Each pair shows the wrong way followed by the right way. */
if($i<7) ...
if ($i < 7) ...
for($i=0; $i<$size; $i++) ...
for($i = 0; $i < $size; $i++) ...

Well, on this note, I usually do insert a space between the keyword and the opening parenthesis, unless the keyword is a function name.

Weedpacket
10-07-2003, 04:49 PM
Originally posted by laserlight
I think I've found a discrepancy in phpbb's coding guidelines:

Of course, that statement in the guidelines is an overstatement anyway .... if it was accurate, then the for loop would be written


for ( $i = 0 ; $i < $size ; $i ++ )

jwb666
10-07-2003, 05:13 PM
yeah phpBB coding standards are cool

and about tabs - although they vary on different programs they still do thier job. Whether the tab is 3,4,5, or 7 spaces, it still idents your code to make it easier to read. and anyway, you can set the tab length on most programs, so set it to your prefered length if you want.

bad76
10-08-2003, 11:08 AM
for ( $i = 0 ; $i < $size ; $i ++ )


I think is more readable any row that fits in the screen than one larger...

... and my screen is not so large... :p

Merve
10-08-2003, 08:38 PM
I use tabs.

Moonglobe
10-08-2003, 09:59 PM
Originally posted by Merve
I use tabs. that's why you're a dork-ass lol :p

LordShryku
10-08-2003, 10:05 PM
HEY!

Merve
10-09-2003, 08:45 PM
I use tabs for large indents.

Moonglobe
10-09-2003, 11:10 PM
Originally posted by Merve
I use tabs for large indents. that makes you more of a dork-ass.



;)

Merve
10-13-2003, 02:41 PM
I use tabs to be a rebel and a dork-ass and to post OT crap in the CC.