RE: PHP Standard style of writing your code

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

 



On 02 May 2006 14:19, Barry wrote:

> > Oh my god -- curly brackets and excessive indentation --
> and curly brackets.  Just a mo, where did I put my
> curly-brackets-and-whitespace-glasses?  Aaaahhh, that's better!!
> > 
> > As you might have guessed, I *HATE* curly brackets with a
> vengeance, which is why I eschew both those styles and use
> PHP's alternative syntax:
> > 
> >   if (...):
> >      if (...):
> >        // mmh
> >      else:
> >        // oh
> >      endif;
> >      while (...):
> >        if (...):
> >          // oh
> >        else:
> >          if (...):
> >            // where am i?
> >          else:
> >            // huh!?
> >          endif;
> >          // hmm
> >        endif;
> >      if (...):
> >        if (...):
> >          // blah
> >        endif;
> >        // blah
> >      endif;
> >   // blah
> >   endif;
> 
> Replacing { with : and } with endif doesn't make it more
> readable at all.

Sez you. To me, it totally does, and by quite a large factor.

> > Just beeeautiful!
> 
> Still extreme compacted code.
> I just see codesalad on first look, nothing else.

Fair enough.  Whereas to me, in any of the curly-brace styles, all I see on a first look is all those curly braces leaping up and trying to scratch my eyes with their sharp little pointy bits.  Each to his own preference.

We should all just say thank goodness PHP lets us each do it to our own preference -- I would daily curse the curly brackets if I had to use your style, and you would long to expand my compact code if you had to use mine.  And at least we can all agree (we can, right?) that almost *any* kind of decent layout is better than:

  if (...): if (...): // mmh
  else: /* oh */ endif; while (...):
  if (...): /* oh */ else: if (...): // where am i?
  else: /* huh!? */ endif; /* hmm */ endif; if
   (...): if (...): /* blah */ endif;
  /* blah */ endwhile; /* blah */
  endif;

Now that's extreme compaction -- and, yes, I have seen code written like that!! ;(

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: m.ford@xxxxxxxxxxxxxx
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211 



To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.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