Re: Tutorial on proper code formating
| From: | Jason Wong | Date: | Thu, 11 Apr 2002 19:06:22 +0000 |
| Subject: | Re: Tutorial on proper code formating | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-92639@lists.php.net to get a copy of this message | ||
On Friday 12 April 2002 02:50, Kevin Stone wrote:
> On the other hand the Inline Method is clean. You can see at a glance
> where each block begins ends. But it is not compact. It spreads the code
> out over many lines. I recommend this method for modern programmers coding
> on large screens. Besides that I think it's just a better way to code.
> More whitespace = less confusion = faster debugs.
>
> /**** INLINE METHOD *****/
> foreach ($mylist as $key => $val)
> {
> if ($key == $list_num)
> {
> for ($i=0; $i<count($key); $i++)
> {
> record_list($key[$i]);
> }
> }
> elseif ($key == $skip_val)
> {
> continue;
> }
> else
> {
> echo "INVALID ENTRY: "$key ." at ". $val . "\n";
> }
> }
> /************************/
I prefer this style because I know exactly where my if statement ends,
especially if you have a humungous nested if-elseif-else construct.
foreach ($mylist as $key => $val) {
if ($key == $list_num) {
for ($i=0; $i<count($key); $i++) {
record_list($key[$i]);
}}
elseif ($key == $skip_val) {
continue; }
else {
echo "INVALID ENTRY: "$key ." at ". $val . "\n";
}
}
--
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
/*
Weiler's Law:
Nothing is impossible for the man who doesn't have to do it himself.
*/