Re: PHP Standard style of writing your code

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

 



Rafael schrieb:
    IMHO, vertical aligned brackets can be messy when nesting
relatively-small blocks (and seems to me like a lot of wasted space)
Huh?!
Show an example. I don't think you will be able to show one.
But this wasted space gives you a lot more insight into the code when looking for loops,whiles,functions and such.

A couple of facts of my codding style:
- I tend to always use brakets, so I ignore the fact that single
  lines/actions can be written without brackets,
This is "your" coding style.
But if you work in a team, and somone does use that because it actually is a neater way of programming.
What do you intend to do?
- I try not to let lines grow larger than about 100 cols (cannot
  be really done with strings and other thingies, and maybe that
  should remain in the old 80 cols, but it's too litle space), and
Never possible if you write web-applications.
CLI might be possible for that but for web it's a no-go.

- I use a 4 space indentation, and that alone suffices for making
  a block stand clear enough
It's not just about one block.
I've seen stuff like:
if (blah blah) {
do my code!
} else {
oh my god!
}

Well, without indentation it just looks like a bunch of chars.

if (blah blah)
{
do my code!
}
else
{
oh my god!
}

Even without intendations, you can clearly see that it's an if and an else here.
The best part here is that you see it when you scroll through your code.
without actually "reading" it.

    So, in my case, the code would be something like
  function foo( $x ) {
      // body...
  }
  ···
  $a = foo($b);
Even this is far too blocky to read.
If you have 4000 rows of code and looking for some if or switch (you are not sure) it would save you a lot of time searching for it though.

And for your problem with viewing. probably try to get a 19" monitor.
They are not that expencive anymore.(The CRT ones)
Even on 1024x768 you see LOTSA code.

--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

--
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