On Fri, 14 Jan 2005 07:50:56 -0800, Sean Corfield
<[EMAIL PROTECTED]> wrote:
> And what would your CommentDAO look like? Would you assume that the
> primary keys for your blog entries and for your products were the same
> type and distinct values? e.g,. use UUIDs for both?

As Hal says, it depends on the context. Right now the context is
arguing the case that this design allows for change and doesn't
inhibit reusability. ;-)

Each comment would have an ID (probably just an integer) that that
distinguishes it from all other comments. But BlogEntry isn't
interested in that ID. All it cares about is the commentNumber, which
is only unique among comments within itself.

So when it's time for BlogEntryDAO to store a blog and its comments,
it knows the blogEntryID and the commentNumber of each comment. It
needs to consult a lookup table (BlogComments) to find the CommentID
for each comment.

BlogDAO then asks CommentDAO to store the comment (passing it the
comment object itself and the commentID).

Products would work the same way.

So CommentDAO would be about as boring as a DAO can be. It would
probably only have three functions.

add(comment) : commentID
retrieve(commentID) : comment
delete(commentID) : comment

> Again, the usage scenarios determine a number of aspects of how you
> design your systems.
Yes, and since we haven't talked about how many products/blog
entries/comments there are or what kind of load the application would
be running under I haven't taken performance into consideration.
That's why I'm willing to ignore the fact that this design is insanely
inefficient. I'm sure it's a good starting point. It may require a few
changes to boost performance. And a lot of it may be handled by
caching mechansims that don't compromise the design much at all.


> I suspect Java folks would immediately think of Commentable as an
> interface and have BlogEntry and Product both implement it (but then
> they'd probably rely on Hibernate to manage all the persistence anyway
> :)
That's cheating. :) But I think we've strayed off topic a bit. The
question isn't "how do we persist comments," but "should blog entries
know about comments or should a third party manage that relationship?"

And that's really an open ended question. We're never going to reach a
"right" answer, but I've kept this thread going because I find it
interesting and I think it's helping me learn about programming.

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]

Reply via email to