First Generic Class
View Single Post
11-29-2007, 05:28 PM
Join Date: Nov 2007
I agree with Karl ... You need to step back and look at the individual roles/responsibilities you are trying to accomplish.
I typically follow the following breakdown when it comes to data drive web site classes:
1. configuration - a place to store constant data (db connection info, etc)
2. Generic database access class (something I can pass queries to and will return results, errors, etc)
3. Data access objects (these are classes that typically represent tables in the database: tags, page_content, users,etc)
the DAOs have a common interface that allows for:
- Make() returns an empty dao object ( not a datarow yet)
- Save( $obj ) inserts or updates the dao object
- Load( $id ) returns a dao object that does represent a datarow based on the primary key (Id) passed
- Delete( $id ) deletes the data row
4. Finally I create a business object to pull things together
you may have methods such as: GetTags( $pageId ) or LoadPageContent( $pageId )
this business object utilizes the multiple daos and provides more automated methods for the webpage to use instead of dealing with daïs and all the logic in the actual web page.
This approach is good practice and is generically, although not strictly, described by MVC: Model, View, Control be describes the separation of application logic into separate layers.
I hope this helps you continue on your quest for the Generic Class!
Last edited by bmicallef : 11-29-2007 at
. Reason: typing on an iPhone is not perfect!
View Public Profile
Send a private message to bmicallef
Visit bmicallef's homepage!
Find More Posts by bmicallef