473,809 Members | 2,591 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

To all OOP eggheads out there. I need A bit of design help

First of all I need to thank you in advance...
Now I 'll try to show you what I want do and if you can, tell me how My
class should be composed.

I have a CMS. I add content and that Content can be Published
Unpublished and Backuped. Now the content has Several Types like...
pages,news,prod ucts.

I am trying to write a class Content that will cover the common bits
that Several Content Types have and the rest will be inherited.

But I don't know how I am going to create different Contents based on
the fact they are Published Unpublished and Backuped. Those three in the
database are different tables.. Published and Unpublished is exactly tha
same table. has a backup_id as a primary key and thats the only
difference from the other two tables... (No I don't want to have
published and unpublished as a boolean)

I was thinking if it is possible to add arguments on the constructor...
so I will have

class Content {
function Content(categor y='unpub') {

}
}

do you have any Ideas... ? Can someone give me a rough idea of how my
class should look like (constructor, the important functions that will
interact with the 3 DB tables)

Thanks A lot...
Dec 2 '05 #1
9 1418
You can try abstract factory pattern to create the content.

Such as, you have an abstract factory class for the content
class Content(){}
class PagesContent : Content()
{}
class NewsContent : Content()
{}
class abstract AbstractContent Factory()
{
public abstract function returnNews();
...
}
class PublishedConten tFactory : AbstractContent Factory()
{
public function returnNews()
{
news=new NewsContent();
news.status='Pu blished'
return news;
}
}
class UnpublishedCont entFactory : AbstarctContent Factory()
{
public function returnNews()
{
news=new NewsContent();
news.status='Un Published'
return news;
}
}
and such. By this design, you can add new content and have classes
based on content and keeping publish status.

Another design would be keeping the publish status in a different class
and associating the content class with this class, if methods would be
the same for all content types.

Dec 2 '05 #2
A. Timurhan Cevik wrote:
You can try abstract factory pattern to create the content.

Will that work on PHP 4 ? or it needs 5 ?
I am working on 4.something...
I'll have a look anyway at your suggestion
Dec 2 '05 #3
C.
Like any database driven program you should start by defining your
schema - i.e. normalise your data. I'm forever finding people whom have
been nitten by the OO bug trying to use persistence as a way of storing
their data - trust me it's a very bad starting point. Trying to fit
your objects and impose persistence on top of an existing schema is a
very bad way to do things.

Assuming that Published, Unpublished and _Backed-up_ are mutually
exclusive and the item must be in one of these states then there should
only be one logical table. These are states of the item (not
properties).

If you can't fix your database schema then using the base class to
abstract the error seems like a good solution.

If there is adequate polymorphism in a relation then WTF do you need to
create derived classes to describe different content types?
C.

Dec 2 '05 #4
Like any database driven program you should start by defining your
schema ?
Thats not the way to oop. Never do that, if you plan to program oop.
Sure, you should do it, but if you are procedural programming or you
lack skills to construct an oo program.

I dont think I made that strong enough, do not start by defining the
schema if you are into oop. Simply do not.

In oop, business layer is business layer. Not the database layer. So,
you should keep your business objects out of persistence code. Doing
not so, makes your code tough to be reusable, encapsulated and such.
Persistence should be handled AFTER the business objects are
constructed and proven to be running good.
It would hurt too to Unit test these classes.
Sure, there are objects that handle persistence. Sure, you can make an
object for each table on your database (Active Record pattern or smth.)
but, that application should not be a big application, if it is, then
you will be making a lot of maintanence, bug fix during the project
lifetime, trying to complete it and trying to change it to meet the
requirements afterwards.

Software change. You should not make it unchangable. So, you should
design it such that changes in layers should affect other layers as
minimum as possible. Highly couling the database schema and the class
structure, you will be violating that.

Dec 2 '05 #5
that is 5 sorry. If you are thinking bout oop, my advice is not to
continue with php 4 and upgrade your current project code to php5. At
least, make it run at php5.

There are just not enough features in php4 to write a full oop program.
A little bit of procedural and a little bit of oop, that would be.
Which is always nearer to pp.

Dec 2 '05 #6
Hello,

A. Timurhan Cevik wrote:
Like any database driven program you should start by defining your
schema ?
Thats not the way to oop. Never do that, if you plan to program oop.
Sure, you should do it, but if you are procedural programming or you
lack skills to construct an oo program.


Ok I see you know what you are talking about and I agree with you.
My problem you see is that At the moment I have a working application
but it is writen in a procedural way and ofcourse I short of have the
database ready... The good thing is that I don't want to migrate
anything from the old system so I start from scratch.

Now if describe you once more my case... would you be able to find me a
solution in the design and how can I simply interpret it in
programing... It is something that I have to have it before christmas
and that makes me nervous...

If you have some time read the case below again otherwise thanks a lot
for your help until now ;)

PHP4 I can't change that.
So here is the case again in parenthesis I will write how I interpret
them in programming:
A content(class) management system will be able to let registered
users(class) to add/edit/delete/publish/unpublish and
restore(content :methods) content.
When the content is added it will be unpublished. Then the user will
publish it. If the content is been edited it, the original version will
stay published but the new version will go be unpublished. Once the new
version is been published the original content gets backuped and the new
gets published.
We can have any type(content:at tribute) of content, starting from
Pages,News,Even ts to Products and Photos.
*************** *************** *************** *************** *************** **
Now that was sort of my case. Can you tell me how would you design the
application and your database ?
And how you would interpret them in very very brief code(Keeping in mind
the PHP Ver4.X.X).

Thank you...
Dec 3 '05 #7
hmmm... As I stated earlier, oop lacks important concepts in php4 and I
dont remember which was included in php4. So, I will not be able to
give you an oop solution. But using simple classes,
- class user
- class ContentContaine r
{
var $contentType;
var $published;
var $unpublished;
function ContentContaine r()
{
$this->published=ne w Content();
$this->unpublished=ne w Content();
}
function Publish()
{// Some business stuff here, maybe database functions
$this->published=$thi s->unpublished;
}
function Restore()
{
$this->unpublished=$t his->published;
}

}
class Content
{
var $Body; // or smth.
var $User;
function Content()
{}
}

I prefer using some ContentMapper class haivng a content attribute for
doing the database stuff, related to a ContentContaine r class,
responsible of retrieving the published and unpublished content from
persistence.

The system could evolve much more, keeping track of user behaviour on
the content, the publishment and editing history etc. Alas I dont have
more time to exercise on it more. I know I did not give you a
fascinating solution, but could give you an idea.

By the way, if you would like to use file locking, file based role
based permission setting, versioning and such, I recommend you to look
at WebDav (some contentmanageme nt low level framework that also has
methods built on top of http like adding put to standart get/post http
methods and being able to reach the repository using Dav:// or smth.)

Dec 4 '05 #8
The system could evolve much more, keeping track of user behaviour on
the content, the publishment and editing history etc. Alas I dont have
more time to exercise on it more. I know I did not give you a
fascinating solution, but could give you an idea.


Your reply was more than helpfull thanks a lot Cevic.

Angelos.
Dec 5 '05 #9
On 2 Dec 2005 12:47:02 -0800, "A. Timurhan Cevik" <at*****@gmail. com>
wrote:
that is 5 sorry. If you are thinking bout oop, my advice is not to
continue with php 4 and upgrade your current project code to php5. At
least, make it run at php5.

There are just not enough features in php4 to write a full oop program.
A little bit of procedural and a little bit of oop, that would be.
Which is always nearer to pp.


I agree with Cevik on this. If you want to redsign your system in PHP
using OO you would be crazy not to use PHP 5. If you use PHP 4 you
will be handicapping yourself unnecessarily for your current CMS
project, and then you will have some more unnecessary work when you do
eventually upgrade that CMS to PHP 5.
Dec 5 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

36
6414
by: Andrea Griffini | last post by:
I did it. I proposed python as the main language for our next CAD/CAM software because I think that it has all the potential needed for it. I'm not sure yet if the decision will get through, but something I'll need in this case is some experience-based set of rules about how to use python in this context. For example... is defining readonly attributes in classes worth the hassle ? Does duck-typing scale well in complex
43
3432
by: Rob R. Ainscough | last post by:
I realize I'm learning web development and there is a STEEP learning curve, but so far I've had to learn: HTML XML JavaScript ASP.NET using VB.NET ..NET Framework ADO.NET SSL
9
1715
by: DP | last post by:
hi., i've got 3 tables, customer, film and filmrental. i've got a customer form, with a sub form at the bottom, which is a film rental subform. i've created an update query, which when a filmid, is entered into the subform, the 'available' check box in the film table, becomes false (Unchecked). according to which filmID it is. heres the code, i;ve got in an
2
1993
by: Steve K | last post by:
I got a bit of a problem I like some help on. I'm designing an online training module for people that work in food processing plants. This is my target audience. These workers have little or no computer knowledge at all! And they also have outdated, old browsers, slow modems, old computers, etc. So I need to keep this as simple as possible and as browser compatible as possible. The client wants a navigation bar at the bottom of each...
16
2824
by: Rex | last post by:
Hi All - I have a question that I think MIGHT be of interest to a number of us developers. I am somewhat new to VIsual Studio 2005 but not new to VB. I am looking for ideas about quick and efficient navigating within Visual Studio 2005. Let's say your project (or solution) has dozens of forms and hundreds or even thousands of routines. Two Questions: 1) BUILT-IN to Visual Studio 2005. What ideas do you have to quickly
15
2587
by: Jay | last post by:
I have a multi threaded VB.NET application (4 threads) that I use to send text messages to many, many employees via system.timer at a 5 second interval. Basically, I look in a SQL table (queue) to determine who needs to receive the text message then send the message to the address. Only problem is, the employee may receive up to 4 of the same messages because each thread gets the recors then sends the message. I need somehow to prevent...
0
5578
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted ******************************************************** For this teeny job, please refer to: http://feeds.reddit.com/feed/8fu/?o=25
1
2345
by: abhijitbkulkarni | last post by:
Hello, I am designing a .NET database application that uses 3 tier architecture. Starting initially, this application will be desktop application but I will convert it into a website later but design that I am planning should support both version. Development Environment : VS2008, C# Currently Database supported are MS SQL Server 2005 and MYSQL 5 and design for database support is extensible. This application contains several high...
53
8431
by: souporpower | last post by:
Hello All I am trying to activate a link using Jquery. Here is my code; <html> <head> <script type="text/javascript" src="../../resources/js/ jquery-1.2.6.js"</script> <script language="javascript" type="text/javascript">
0
10643
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10378
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10391
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7664
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5690
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4333
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.