Reply to Re: Coding style...

Your name:

Reply:


Posted by Curtis on 01/02/06 23:20

Lόpher Cypher <lupher.cypher@verizon.net> wrote in message
news:te6uf.1513$494.916@trndny07...

> Btw, I prefer to rather escape quotes (\"). I believe ""
is a standard
> for xhtml, and there was some slight difference between ''
and "" in
> php. However, for strings in php, you can't go wrong with
"" :)

I suppose not. In theory, I lean toward what another poster
suggested--if you're not embedding variables, using
'text="foo"' is cleaner than "text=\"foo\"". But in
practice, one embeds variables so often--and uses regular
expressions that make PHP's syntax a cakewalk by
comparison--that I'm almost always escaping full quotes, as
you suggest.



> > While I'm on the subject, I note that a lot of PHP
coders do
> > the opening braces like so:
> >
> > <?php
> > if ($something) {
> > do this();
> > } else
> >
> > dothat();
> > }
> > ?>
> >
> >
> > I don't find this as readable/maintainable as lining up
> > opening and closing braces the same way I would line up
> >
> > begin
> > begin
> > end
> > end
> >
> > in Pascal--especially when things get nested three or
four
> > levels deep.
> >
>
> I started programming in Pascal, and when I started
learning C++, and
> later C-like-syntax languages, I was finding pascal-style
blocks better.
> But I think that for C-like-syntax languages opening
blocks with a brace
> on the same line is so common that one can say it's a
"standard" :)
> Anyways, you'd get used to it over time :)

I hope not. Heh.

A person can get used to about anything, but it just makes
too much sense to me to use the visual symmetry of

{
{
{
}
}
}

I can't think of a good reason NOT to, with the exception of
some additional vertical white space. And that's not so bad,
as I like to comment from the 50th column to the 80th, and
that white space is often good for comment continuation.
Like so:

1 50
____________________________________
if (!$skip) # If comment
{ # really vital
codestuff(); # do it here.
}



I find that MUCH easier to read than:

// Do the foo to the fee because bar.
if (!$skip)

codestuff();
}

// More comments blah blah blabbity-blab.
if ($skyisfalling) {
morecodestuff();
}

My style was almost a requisite back in the days of assembly
language programming, and with good variable name selection
code is more self-documenting these days, but I find the
style still has a lot to be said for it, particularly if the
coder comments about the nonobvious aspects of the
algorithm.


--

Curtis

Visit We the Thinking
www.wethethinking.com
An online magazine/forum
devoted to philosophical
thought.

[Back to original message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация