Re: PHP Standard style of writing your code

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

 



On Tue, May 2, 2006 3:02 am, Barry wrote:
> 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.

if (...)
{
  if (...)
  {
    if (...)
    {
      //blah
    }
    //blah
  }
  //blah
}

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

Grin and bear it.

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

YES!!!

Without indentation you are SCREWED.

Nobody is arguing against that!

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

Bzzzzt.

Without indentation, it's just garbage.

> The best part here is that you see it when you scroll through your
> code.
> without actually "reading" it.

If you indent, you see it as you scroll through without actually
"reading" it no matter where you put the braces.

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

I frequently code on smaller monitors -- laptop, ancient desktop,
stripped-down flat-panel monitor that fits inside a rack-mount 2-RU
shelf in my sound booth...

I can't really lug a 19" monitor all over, and there's no room in my
sound booth for it, what with the amps, sound boards, computer, CD
duplicator, etc.

-- 
Like Music?
http://l-i-e.com/artists.htm

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