17 March 2011

Gold Star from the Master

In my HTML class we were tasked with making a web "site" (it only has two pages and thus can hardly be called a "website") that was as dynamic as possible. (This means that we were supposed to be using a lot of PHP code so that there isn't a lot of HTML to update when things change.) We were mimicking a mock of Facebook called Critterbook that the teacher gave us. He gave us the graphics and text (no style sheet to make it pretty, which I am struggling with making or other code). So I spent Saturday morning building the required two pages (you can see them here) and then was inspired to add some cool new code:
$files[] = substr($filename,0,(strlen ($filename)) - (strlen (strrchr($filename,'.')

To be honest, I added the code because I did not want to be too far behind the codemaster who sits next to me in class (no, really, he is a nearly graduated Computer Information Technology major who knows more programming languages than I know foreign languages--even counting the languages that I only know a handful of words in). When we got to class we compared projects and he had something like this:
$files[] = array("mule.php" => "Mule", "chicken.php" => "Chicken"))

The garbably-goob is the cool difference. His code (the standard that most of us shoot for) basically says: "If you have a friend named 'Mule' then link it to mule.php and if you have a friend name 'Chicken' then link it to chicken.php." That was fine, and definitely high standard for the class, but this list would need to be updated whenever a new page was added, and I, being a lazy programmer, am not okay with constantly updating random strings.

My code on the other hand says: "Look, I am a lazy web site builder and I don't want to have to tell you every time I add a page, besides you are a big web server wearing big web server pants, so go write your own list, make it pretty and keep it up-to-date."

That earned me a Gold Star from the codemaster. It still makes me smile.

No comments:

Post a Comment