[UPHPU] OOP continued (was: "Article 3 posted")

Jeffrey Moss jeff at opendbms.com
Wed Jun 29 11:58:58 MDT 2005

That's a pretty bold statement you make about OOP programmers. I think what 
you're missing here Josh is that once you start putting your functions into 
libraries and using global variables and some sort of namespace identifier, 
ie: WebApp_version instead of WebApp::version, you might as well be using 
classes. This argument that functional programming can be just as well 
organized and easy to use as OOP is incorrect. The difference is if you need 
a string that behaves differently in a procedural language like C, you must 
write a function that handles the string differently and call it in your 
application, no matter where you define the function it is still being 
called in your application, while in PHP or C++ you could make that the 
default behavior of the string or string-like object, and the guy updating 
your code may never even have to know about it.

Here's a good example from my O/R presentation, the "dybase" object oriented 
database system. You probably use databases in 95% of your applications. You 
just can't get this level of organization (or power for that matter) without 

include "dybase.php";

class Person extends Persistent {
    public $name;
    public $height;
    public $weight;

    public function __construct($name, $height, $weight) {
        $this->name = $name;
        $this->height = $height;
        $this->weight = $weight;

class Root extends Persistent {
    public $people;

$db = new Storage();
if ($db->open("test.dbs")) {
$root = $db->getRootObject();
    if ($root == null) {
        $root = new Root();
        $root->people = $db->createStrIndex();
    $jeff = new Person('Jeff Moss', 75, 200);
    $root->people->insert($jeff->name, $jeff);

I really find it hard to see how you think procedural code is "better" in 
any way other than speed. If you weigh in the time it takes to come up with 
an SQL database schema, this method is also as fast or faster in terms of 
development, *especially* in the really simple apps. You could make any 
object a "Persistent" object and throw it into your database. It's too bad 
the relational database model is so prevalent as it seems to encourage 
people to avoid the use of classes in their data model. As I said in my 
presentation, by using an O/R mapping package it makes OOP come more 
naturally for your entire application, you'll have to go out of your way to 
write procedural code.

OOP is just one higher level of abstraction, there's also aspect oriented 
programming, goal-oriented programming (or unit-testing)... someone came up 
to me after the O/R presentation and brought up unit-testing, I slapped my 
forehead cause I meant to talk about it... it can make OOP much easier to 
grasp. Web services are another model being employed these days, you write 
your app with an underlying web service and do the frontend separately, the 
web service acts as an "agent" which is able to communicate with other 
agents. It may seem like a waste of time until you want to link your 
application with paypal or google or something, or if you need to "scale 


More information about the UPHPU mailing list