|
Posted by Michael Fesser on 08/14/07 15:06
..oO(Pavel Lepin)
>The code I posted follows the PHP coding style guidelines
>(the variant for short code snippets in our dev dept's CMS)
>of the organisation I'm working for.
I've seen many coding guidelines (for PHP, C/C++, Java, Pascal etc.),
but it's the first time I came across something like you posted. Just
two examples:
foreach
(
...
)
vs.
for (...)
Where's the logic in that? Sometimes a line break in a control
structure, sometimes not? Same here:
$curDoc->appendChild
(
$curDoc->importNode ($doc->documentElement , TRUE)
) ;
vs.
$curDoc->documentElement->appendChild
($curDoc->importNode ($info , TRUE)) ;
Illogical (IMHO).
>other people might actually
>find the code easier to read in the style I used
I really doubt that, but YMMV. For example it's quite common to _not_
put a blank between a function name and its arguments, simply because it
can be confused with a control structure or a property in OOP. If you
like that - OK. But you should also think about other coders that might
read your code. Especially about inexperienced coders who are asking for
help in a newsgroup.
>It's a matter of perception, and if you believe
>there's any sort of consensus on preferable coding style
>even in PHP community alone, you're sadly mistaken.
Of course there's not the one and only coding style (and never will),
but there some very basic rules, which are a part of most if not all
guidelines. Call it common sense.
Micha
[Back to original message]
|