Re: SHOULD I NOT USE "ELSE" IN IF STATEMENTS....?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Colin Guthrie wrote:

> 'Twas brillig, and O. Lavell at 08/06/09 16:33 did gyre and gimble:

[..]

> So personally I like early return. I use it mostly to cut down brace and
> indentation churn. I try to keep code into 80 cols and if 40 of them are
> used up with indents that doesn't leave much room for the actual code!

I disagree with you on quite a few points obviously, so let me just 
respond to your statement above. You seem to be saying that if we are 
indenting to column 40 in our code we are doing something wrong, yes? I 
agree on that. But now, I would say the same thing about your example 
with "several pages of code" inside an "if" clause.

The remedy in both cases should be to make our code more modular. Create 
handy objects, compact functions and the occasional include file (e.g. 
for HTML). Whatever really, to split things up into well-manageable 
parts. This improves readability enormously. It also helps you 
concentrate on solving smaller problems instead of larger ones, which may 
benefit your own productivity as a coder as well.

I try to never write anything much longer than about 15 or 20 lines of 
PHP. Whatever part of the whole it is, like a function most likely, it 
needs to do its task within that constraint. Doesn't always work out of 
course, but I get close enough often enough. HTML I have to deal with is 
another matter obviously. Though sprintf() is fantastic help there :)


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux