views:

396

answers:

3

I have two classes, but don't what kind of relation i should use. I have a class Document with a lot properties and no methods. The second class is what i called the DocumentFact (Fact - Factory). This class contains different methods which returns a collection of Document objects.

So, the Document class doesn't know anything about the DocumentFact class because it has nothing to do with it. On the other hand, DocumentFact creates multiple Document objects. What kind of UML relation is this? I was thinking something like this:

--------------           ------------
|DocumentFact|  -------> | Document |
--------------       2.* ------------

Or:

--------------            ------------
|DocumentFact|  ------- []| Document |         // Composition
--------------            ------------

What do you think?

+3  A: 
toolkit
+1  A: 

I agree with toolkit that factories->product is an instantiates relationship - the multiplicity descriptor doesn't apply unless the factory is also intended to maintain references to the product objects in which case it's a 1:* or 1:n (multiton) anyway

annakata
+3  A: 

Just my opinion - if DocumentFact truly is a Factory, I'd spend the extra three keystrokes and spell it out. You force users of your class to figure out whether you mean "document factory" or "fact about a document" when they read the class name for the first time. The uncertainty is unnecessary, especially if you can touch type. I'd recommend making the name more self-documenting and less ambiguous.

duffymo
Off-topic, but a very good advice!!!
Yarik