Posted by A. Timurhan Cevik on 10/03/66 11:33
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 AbstractContentFactory()
{
public abstract function returnNews();
...
}
class PublishedContentFactory : AbstractContentFactory()
{
public function returnNews()
{
news=new NewsContent();
news.status='Published'
return news;
}
}
class UnpublishedContentFactory : AbstarctContentFactory()
{
public function returnNews()
{
news=new NewsContent();
news.status='UnPublished'
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.
Navigation:
[Reply to this message]
|