February 03, 2005

PHP & OOP

Lets say I'm building this class *Manager* that acts as a database table manager (much like you would find in phpmyadmin, but more user-friendly for folk's who aren't tech saavy).

I want *Manager* to show me the contents of the given table, insert records, update records, and delete records. (pretend that my code is neatly indented...)

class Manager {
function __construct($Table) {}
function showReport(?) {} // Builds a Report with the Table Data
function insertRecord(?) {} // Inserts a Record into the Table
function updateRecord(?) {} // Updates a Record in the Table
function deleteRecord(?) {} // Deletes a Record in the Table
}

To maintain OOP principles, do I build the control-flow into the class,

function process() {
if ( something ) {
// Check for Errors
// Perform some Action
} else {
showReport();
}
}

or do I use procedural code (outside of the class) to do control-flow?

$Manager->insertRecord(table data goes here);
$Manager->showReport();

Posted by kposey at February 3, 2005 02:55 PM | TrackBack
Comments
Post a comment









Remember personal info?