Re: [PHP] Re: PHP Coding Standards
On 02/06/2004, at 3:00 AM, Justin Patrin wrote: And I'm one of them. :-) I like the KR version because it saves verticaly space and most editors can't really handle correct tabbing when you put it after. IMHO it's just not necessary as ALL blocks should have braces, even those that are one-line. If you always use the braces, you can looks for indenting as the open of the block and the end-brace (and un-indenting) as the close of the block. I used to be a big fan of both versions, but honestly, I didn't care, as long as an app was consistent, so that one could become comfortable with it over time. The reality is that good editors like BBEdit can help match braces, highlight code blocks, etc. But recently, I've changed my tactic to whatever helps the code be as readable and clear as possible... $file = 'a'; if(file_exists($file)) { include($file); } $file = 'b'; if(file_exists($file)) { include($file); } $file = 'c'; if(file_exists($file)) { include($file); } else { include('x'); } $file = 'd'; if(file_exists($file)) { include($file); } else { include('x'); } $file = 'e'; if(file_exists($file)) { include($file); } is a lot clearer,line-efficient and faster to comprehend than... $file = 'a'; if (file_exists($file)) { include($file); } $file = 'b'; if (file_exists($file)) { include($file); } $file = 'c'; if (file_exists($file)) { include($file); } else { include('x'); } $file = 'd'; if (file_exists($file)) { include($file); } else { include('x'); } $file = 'e'; if (file_exists($file)) { include($file); } Of course, looping through an array of file names would be even clearer, but you get my point :) --- Justin French http://indent.com.au -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP Coding Standards
On 31-May-2004 Travis Low wrote: I have to say I like everything about the PEAR coding standards except for the KR bracing style. I much prefer: if( foo ) { blah; } Icky. So ... Vee-Eye or Eighty Megs and Constantly Swapping ? ;- -- Don Read [EMAIL PROTECTED] -- It's always darkest before the dawn. So if you are going to steal the neighbor's newspaper, that's the time to do it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP Coding Standards
Travis Low wrote: I have to say I like everything about the PEAR coding standards except for the KR bracing style. I much prefer: if( foo ) { blah; } to if( foo ) { blah; } The latter form (KR) conserves vertical space, but I find it a lot harder to follow. Harder to move blocks of code around too. I'm sure plenty of people disagree, so of course this is IMHO. And I'm one of them. :-) I like the KR version because it saves verticaly space and most editors can't really handle correct tabbing when you put it after. IMHO it's just not necessary as ALL blocks should have braces, even those that are one-line. If you always use the braces, you can looks for indenting as the open of the block and the end-brace (and un-indenting) as the close of the block. cheers, Travis Michael Nolan wrote: charles kline wrote: Hi all, I was having a conversation with a friend and talking about coding standards in the open source community (focusing on PHP). I seem to remember there being a document out there that sort of laid it out pretty well. Anyone know where I might find a copy? PEAR has a page in their documentation about coding standards: http://pear.php.net/manual/en/standards.php HTH, Mike -- paperCrane Justin Patrin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP Coding Standards
Justin Patrin wrote: Travis Low wrote: [I hate KR indenting] And I'm one of them. :-) I like the KR version because it saves verticaly space and most editors can't really handle correct tabbing... Arrggghh...TABS. Don't even get me started on tabs... cheers, Travis -- Travis Low mailto:[EMAIL PROTECTED] http://www.dawnstar.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: PHP Coding Standards
[snip] [I hate KR indenting] And I'm one of them. :-) I like the KR version because it saves verticaly space and most editors can't really handle correct tabbing... Arrggghh...TABS. Don't even get me started on tabs... [/snip] How many holy wars can be started in one thread legally? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP Coding Standards
Travis Low wrote: Justin Patrin wrote: Travis Low wrote: [I hate KR indenting] And I'm one of them. :-) I like the KR version because it saves verticaly space and most editors can't really handle correct tabbing... Arrggghh...TABS. Don't even get me started on tabs... cheers, Travis I meant indenting. I won't get into tabs vs. spaces here. ;-) -- paperCrane Justin Patrin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP Coding Standards
Travis Low [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I have to say I like everything about the PEAR coding standards except for the KR bracing style. I much prefer: if( foo ) { blah; } to if( foo ) { blah; } The latter form (KR) conserves vertical space, but I find it a lot harder to follow. Harder to move blocks of code around too. I'm sure plenty of people disagree, so of course this is IMHO. Hi Travis, I totally agree with you. I'm coding this way: if (foo) { // code } elseif (bar) { // code } else { // code } This makes it very easy to follow if/elseif/else structures in code. But the PEAR style is the one usually used in Java as well so I guess it's the style most people use. Regards, Torsten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP Coding Standards
I have to say I like everything about the PEAR coding standards except for the KR bracing style. I much prefer: if( foo ) { blah; } to if( foo ) { blah; } The latter form (KR) conserves vertical space, but I find it a lot harder to follow. Harder to move blocks of code around too. I'm sure plenty of people disagree, so of course this is IMHO. cheers, Travis Michael Nolan wrote: charles kline wrote: Hi all, I was having a conversation with a friend and talking about coding standards in the open source community (focusing on PHP). I seem to remember there being a document out there that sort of laid it out pretty well. Anyone know where I might find a copy? PEAR has a page in their documentation about coding standards: http://pear.php.net/manual/en/standards.php HTH, Mike -- Travis Low mailto:[EMAIL PROTECTED] http://www.dawnstar.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP Coding Standards
charles kline wrote: Hi all, I was having a conversation with a friend and talking about coding standards in the open source community (focusing on PHP). I seem to remember there being a document out there that sort of laid it out pretty well. Anyone know where I might find a copy? PEAR has a page in their documentation about coding standards: http://pear.php.net/manual/en/standards.php HTH, Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php