List of variable names, oddly named and other stuff I’m glad I bumped into
. Found them in project about 5 or 6 yrs old that needs modification and I believe optimization too, yes really. So why glad? Because I realized the way I named my variables isn’t that bad at all.
/** * This one is on top of a movie player page. Maybe 'he' wasn't so sure * that the parameters passed on to this page is for a 'video'. Just making * sure for the nth time I guess. */ $videoistrue=0; /** * I think 'he' hate lines. And this one is good, page title is saved * in a session variable, so if another programmer writes a new page * and forgot to assign $_SESSION['pagetitle'] a new value for an FAQ * page, say faq.php, it'd show up <title>Show Series</title> */ session_start();$_SESSION['pagetitle'] = "Show Series"; /** * ... and it went on and on * $_SESSION['pagetitle'] = "Calendar"; * session_start();$_SESSION['pagetitle'] = "Browse Model"; * * Hmmmm, $ii as iteration variable, struggling with names? I often * use $i, $n or $x, sometime $c, hehehe! I've seen $i for many. And * have you noticed the class name 'smalleditnoline', can it be any * longer? Yes! and if he had enough time, it may have look like * 'smalleditnolinewitharialbold' or 'smalleditnolineFFFbgcolor333fgcolor' * crazy! This is CSS anyway, will surely post one for that, hahaha! */ for ($ii=1;$ii< =$totalpages;$ii++) { if ($ii==$page) { echo "<font class='smallediton'>[$ii]"; } else { echo "<a href='?sort=" . $_GET['sort'] . "&page=$ii' class='smalleditnoline'>[$ii]</a>"; } } /** * more variables with default values, note that this is set just * before a loop starts */ $thisCat = ""; $firstrun = true; $firstrow = 0; $rowcount = 0; /** * "NO QUOTES" for key names in square brackets :( * if only my IDE could complain */ $GLOBALS[catadded] = false; $GLOBALS[keywordadded] = false; $GLOBALS[modeladded] = false; /** * Consistent! Maybe 'He' doesn't want anybody to easily understand * the script that's why no new lines after semi-colon at least. */ if ($seriesRow[seriesNo] < 10) $seriesNoTxt = "0".$seriesRow[seriesNo]; else $seriesNoTxt = $seriesRow[seriesNo];
Ok, enough of grumbling here. I have released my frustration for today, going back to work. But if I am to start a project or even a simple script, I follow formatting conventions, consistent quotes and escapes, logical variable names and useful comments with links and samples. It doesn't only make your code readable, it helps a lot for the next programmer to just add-in the stuff he needs to and keeping his sanity.