[PHPwestoz] Good coding practice (article)
Ady at kiltotter.com
Mon Mar 21 09:54:02 UTC 2005
I personally know that there are many ways to create variable names,
structure your code, and so on.
What I am more interested in is the key pointers, such as consistency,
legibility and usability.
What is useful for many programmers, web developers and those learning PHP
for the 1st time, is that a set of guidelines can be referred to so that
they may then construct their own system, if they do not like one that is
proposed, and then stick to it.
I¹ve gone through a variety of standards, but it depends on what I am doing
at any one time.
Comments, as you say, where do you say it is too much? I like to try to
comment extensively at the start of any function (not looked at the PHPdoc
systems yet), then when needed explain a bit of code that looks tricky¹. I
also comment code blocks to show what happens in them. Personally I always
try and put // end for or // end while or similar into the code to show the
end of a particularly long loop.
With my students I try and get them to do the same even with short loops, if
statements and more. In the end when they combine this with consistent
indenting it creates a much better understanding of what they are doing.
One way of helping this will be a good code beautifier system for XHTML,
the same time. Now that would be a nice Open Source project, if it is not
one already. Beautifying the code of all four languages at the same time
would be simply wonderful.
Anyhow, sorry for slow reply, [I may have replied before, but cannot
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the PHPwestoz