|
Posted by Steve on 10/25/06 17:43
"JM" <reply@group.svp> wrote in message
news:p7qdnVHXdvDcEKLYRVnyjw@scarlet.biz...
| I'm studying for webdeveloper. The trainer only comments when it doesn't
| work, but I am also interested in comments on programs or pieces of code
| that work : can it work better, faster, shorter, ...
| I made an object to show a monthly calendar using PHP, OOP and DOM (and
| MySQL). If possible I would like some more experienced programmers to
| review/comment my code (logic, design, code, names, ...). I hope to
| learn from it.
| For more information, an example and to download the code :
| http://www.johan-mares.be/webdevelopment.php?htt=6&lang=en
it's pretty basic. i'd like to be able to pull up event details in another
window, OR, have a "back" button on the day's detail so i can see the
calendar for the month again.
as for your code. i applaud your use of comments but i'd MUCH rather see
well formatted code! ex.,
private $mMonths = array("januari", "februari", "maart", "april", "mei",
"juni", "juli", "augustus", "september", "oktober", "november",
"december");
private $mMonths = array(
'januari' ,
'februari' ,
'maart' ,
'april' ,
'mei' ,
'juni' ,
'juli' ,
'augustus' ,
'september' ,
'oktober' ,
'november' ,
'december'
);
which is easier to read? i put all my code in block form. code is easier to
read in blocks rather than like reading a book from left to right. i also
try to align variables with values:
$foo = 'bar';
$thisMonth = 'oktober';
$yesterday = 'tuesday';
also note that i use a tic (') instead of quotes (") in most places as
quotes are parsed by php. no need for such parsing in the above.
i saw your experience is in .Net. php doesn't use "m" for "modular" as in
$mMonth...php best practices are using an underscore: $_month. all $_
variables are assumed to be within the scope of the object only.
do not arbitrarily wrap function parameters among multiple lines. either
make all paratemeters of a function on one line, or each on its own line:
someFunction($paramA, $paramB, $paramC);
or
someFunction(
$paramA ,
$paramB ,
$paramC
);
i saw some other things going on in your code, but these are my main
pet-peaves. my biggest is the formatting of in-line sql...your's is
passable. ;^)
hth,
me
[Back to original message]
|