On Tue, Feb 22, 2011 at 14:15, Marc Guay <marc.g...@gmail.com> wrote:
> It's an interesting idea (a different take on coding best practices)
> but I find the PHP example to be laborious and time consuming with
> little benefit.  If I'm typing an IF statement, I hope to god I know
> what the condition is before I start typing it.  Creating the if/else
> structure first and then filling in the conditions after is a lot of
> cursor-shuffling that could be lived without.

If the if statement is simple, then I do agree with you. But once
there are nestled functions or conditionals, I like to have the layout
already ready. Consider:

if ( someFunction( someCheck( srrtolower( $_POST["variable"] ) ) ) ){
    // Some Code

Now, after the $_POST variable, how many close parentheses does the
code need? This does trip up beginners, especially those who
rightfully learn outside an IDE. Similar situations occur for
something like this (unindented to not overflow email line character
function someFunction(){
    // Some Code

Writing that is fine, but if the user goes in to add another while or
if, he will get lost in the sea of parenthesis. Therefore, I always
close elements before filling them in. It keeps the mind's state
machine saner!

Dotan Cohen


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

Reply via email to