It's a balance between commenting the code enough to be able to develop and
re-develop the conde without much grief.
As I move through from being a newbie to somebody who spends 80% of their
day working with PHP, I've discovered that a LOT of what I used to comment
was just pointless, because a quick glance at the code could tell me exactly
the same thing.
So now I tend to comment less, and when I do, it talks about what's
happening on the next 5-50 lines, NOT what's happening only on the next
single line.
Way too many comments:
<?
// today as a timestamp
$today = time();
// the other date
$theOtherDay = '2003-11-21';
// convert to timestamp
$theOtherDay = strtotime($theOtherDay);
// get difference
$diff = $today - $theOtherDay;
// round it to the nearest whole day
$diff = round($diff,0)
// print to screen
echo "The other day was {$diff} days ago";
?>
Could be:
<?
// find the difference between today and the other day,
// then round it to the nearest whole day and print
$today = time();
$theOtherDay = '2003-11-21';
$theOtherDay = strtotime($theOtherDay);
$diff = $today - $theOtherDay;
$diff = round($diff,0)
echo "The other day was {$diff} days ago";
?>
... it still tells me broadly what happens, but doesn't hole my hand through
every line.
Just my two cents worth -- and yes, I'm fully aware that the example can be
optimised into better code :)
Justin
on 13/03/03 12:38 AM, Mathieu Dumoulin ([EMAIL PROTECTED]) wrote:
> I'm programming large web solutions here and a new programmer has given me a
> warning about how much comments i put in my code and said that it could
> probably lower effiency when parsing and executing the php code in my
> documents.
>
> So my questions are:
> Does putting huge amount of comments in a file really lower the parsing,
> compilation and execution time?
> Using Zend Optimizer, which is the case right now, would it be better if it
> did slow down the code?
>
> Thank you in advance
>
> Mathieu Dumoulin
> www.groupimage.com
> Web solution Programmer/Analyst
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php