The wonders of OOP

Categories: uncategorized

Date: 10 July 2006 22:52:05

You know how earlier in the year I was lamenting the fact that this OOP thing was OK, but I didn't really Get It? Well, I think I get it now, and all thanks to a conversation with the great M@ about equine genitalia. I kid you not.

So the new Wiblog system is being built using really simple code like this (don't try to run this psuedo-PHP, it's not real).


// create the new page
$page = new Page;
// set the new page title
$page->title = "Entries for ".$page->selectedMonthName.", ".$page->selectedYear

// create the new entries object
$entries = new Entries;

// set the parameters for the entries we want to fetch
$entries->year = $page->selectedYear;
$entries->month = $page->selectedMonth;

// get the selected entries
$entries->getEntries();

// loop the entries
foreach($entry in $entries->entryList){
// write out this entry to the page content
$page->content .= $entries->draw($entry);
}

// create the page links for multiple pages
$page->pageEntryLinks($entries->totalEntries);

// write out the page
$page->draw();

Isn't that easier than writing the whole thing from scratch every time?