Recent Topics

Needs some guidance from OOP web developers

Started by on Jan 03, 2007 – Contents updated: Jan 03, 2007

Jan 03, 2007 15:09    

Ok, I've put together a generic system that is contains the DataBase and DataObject class, now what happens is that it imports a datastructure array and then it will generate all the display, adding, updating, removing, etc that needs to be done.

Now thats all good and dandy, now what i do is i have classes that extend the DataObject class that require additional or customized functionality, eg. the folloring classes; Category, Product, etc.

Now thats all good and dandy, until i get to customizing the display.

As in my DataObject class i have a display function, that will display the add/update/view pages (in generic form).

So then lets say for the Products class i have;
function display($display, $i = 1, $n = 2)
So then if $display = 'create' it will display the create page, now the $i and $n vars are so i can do a loop through all the products and do this;
$Product->display('view-public-list', $i, $n); // where $i is the current index of the product in the returned products, and $n is the total products.

Now thats kinda still dandy, but the problem then gets to adding real custom pages like;
etc etc

And i also have things like

And then it just becomes a huge hassel, as customizing things in different displays becomes quite a task.

So what i'm thinking of doing is cutting out all display from within the non generic class (DataObject).

So instead of having $Shop->display('public-products'); i would just use the classical files approach instead of using functions.

Having the display inside the classes is a good idea by theory as you can just take the class and plug it in, and you get all the display, as what happens with the DataObject class. But when you need to have specific pages or lots of them, and different displays for say the 'title' field for some of the different pages, then it just becomes a hassle, as you need to find and change a lot, instead of just the part you want. But having it so it doesn't use those functions means that you cannot just plug and play in that sense, and there would start to become duplicated code as functions are not used. BUT the thing is, it's not plug n play anyway for customized displays, as say $Shop->display('admin-page'); still requires a admin-page.php to be set up in the admin url, as do all the links need to be set up. As like $Product->display('admin-list', $i, $n); would contain links to $Product->Shop->admin_url.'admin-page.php'; where that admin-page.php would just contain $Shop->display('admin-page'); are you seeing where the hassle is coming in?

Any help would be great.

Jan 09, 2007 15:43

For anyone interested, i've solved the problem by taking the display out of the classes, by next week i will have more info on the problem and it's solutions.

Form is loading...

powered by b2evolution – This forum is powered by b2evolution CMS, a complete engine for your website.