Re: Re: PHP Coding Standards

From: Date: Thu, 03 Jun 2004 02:30:43 +0000
Subject: Re: Re: PHP Coding Standards
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-187503@lists.php.net to get a copy of this message
On 02/06/2004, at 3:00 AM, Justin Patrin wrote:
And I'm one of them. :-) I like the K&R 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

« previous php.general (#187503) next »