The idea of throwing in a Photo as a type of blog entry (and also
allowing it to have comments) is a nice way to expand the discussion and
see how the various approaches will accommodate change!

First, the decision must be made if the "PhotoArticle" really needs to
be a new class, or if an image property could just be added to the
existing Article. Are we talking about a blog article that also has a
picture? Or is the PhotoArticle something totally different (maybe there
are no teaser or body content associated with it? It's just an image and
a thumbnail). This decision would drive the solution.

But if the decision is that PhotoArticles ARE different enough to be new
objects, my take would still be using the manager to handle the
relationship between the BO's and the DAO/Gateways. 

Polymorphism would be an aid in this case.

Say you have a BlogContentManager. And say you have an abstract class
called BlogContent, which is subclassed by BlogArticle and BlogPhoto
(and any future types of blog content). If we decide on a standard
interface for all of the subclasses of BlogContent, then the
BlogContentManager would only need to deal with the BlogContent objects.
It would never know whether any given object was actually a BlogArticle
or a BlogPhoto.



> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf
> Of Patrick McElhaney
> Sent: Wednesday, January 12, 2005 10:54 AM
> To: [email protected]
> Subject: Re: [CFCDev] When to Use Composition (Was: Newbie
approach...)
> 
> On Wed, 12 Jan 2005 15:27:24 +0000, Greg Stewart
<[EMAIL PROTECTED]>
> wrote:
> > Not to throw a spanner in the works, but since we are talking about
a
> > blog, what if you wanted to extend it, to be say a photo Blog. Photo
> > blogs can also have comments
> 
> Great question. One solution would be to create a BlogEntry, and have
> Article and Photo extend BlogEntry. Then move the functions related to
> comments up to BlogEntry.
> 
> I would also have to create a BlogEntryDAO and have have ArticleDAO
> and PhotoDAO extend it.  BlogDAO would persist the comments and any
> other attributes that are common to both articles and photos (title?
> date?). ArticleDAO and PhotoDAO would persist the parts are specific
> to them.
> 
> I understand that when OO gurus have to make a change they prevent
> themselves from having to make the same type of change in the future.
> BlogEntry is now closed against new kinds of content. If I want to add
> videos to the blog, all I have to do is create a couple of new CFCs
> that extend BlogEntry and BlogEntryDAO.
> 
> > Usual disclaimer about possibly being way of track applies here...
;)
> Ditto.
> 
> Patrick
> 
> 
> 
> 
> --
> Patrick McElhaney
> 704.560.9117
> http://pmcelhaney.blogspot.com
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email
> to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev'
> in the message of the email.
> 
> CFCDev is run by CFCZone (www.cfczone.org) and supported
> by Mindtool, Corporation (www.mindtool.com).
> 
> An archive of the CFCDev list is available at www.mail-
> archive.com/[email protected]

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at 
www.mail-archive.com/[email protected]

Reply via email to