Maintain 3.0
December 21st, 2005 by ZackThe project I am working on is called Maintain. It was the first project of the Open Source Lab to aide the move of Oregon State University from orst.edu to oregonstate.edu. Up until then the network at the university had been managed by a bunch of scripts that were very well done but fairly inflexible. Maintain allows you to manage a large number of network configuration options and have them dynamically “pushed” into service at the speed of a cron job. Maintain is written in PHP4 and suggest the use of MySQL and Apache.
The project is currently going through a total rewrite. Meaning everything was scrapped and we are starting from scratch. The old maintain code was elegently done yet ugly and (in my opinion) unmaintainable (no pun intended). The code weaved in and out of php and html making it imossible to read or follow. Daniel Roberts and Michael Clay decided to use a package called phphtmllib to solve the presentation problem. This package lets you handle all of the html presentation stuff in php in an… OBJECT ORIENTED way. This makes the entrire project written in php and very easy (and fun) to use. It feels a lot like other GUI frameworks out there that were not intended for the web. So now that we have a good way to handle the html documents there was still one big problem in my opinion. Each object in Maintain handled it’s own database access… yada yada. The SQL statements for saving, reading, deleting and modifying the data in the database were hardcoded into the object definitions AND even worse: the html pages themselves! This is an easy way to code on the fly but again makes it very hard to maintain, reuse, and modify.
This problem was solved with the use of the pear packeage DB::Dataobjects. The package generates SQL and class definitions based on database tables. And in the code you can use it like this
$person = new Person(16);
which would instantiate a Person object and fill it out with all of the data in the database with id = 16;
or to do searches
$person = DB_DataObjects::Factory(”person”);
$person->eyeColor = “red”;
$person->find();
would return to you every person object that has eye color of red.
Anyway, DB_Dataobject solves the problem very well and we now have a very object oriented application that started out nothing of the kind.
You can “try out” the old version of Maintain (Maintain 2.4) at:
https://maintain-demo.dev.osuosl.org
Since our new rewritten version (3.0) is not stable and currently lacks a lot of functionality I suggest trying the old version. The goal is to have the new version look exactly like the old, which, is kind of ironic.
It has been a great experience working with the guys at the lab and and I look forward to the rest of the time that I have there.
P.S.
Is it weird that when I first wrote this choosing the eye color of “red” in my example didn’t seem a little odd?

