Question

i dont have an idea what the broken arrow from the ConcreteCreator to the ConcreteProduct means. i searched in the internet and i came up with "Dependency". can someone explain the dependency in layman's terms? thanks!

alt text

image grabbed from http://www.dofactory.com/Patterns/PatternFactory.aspx

Was it helpful?

Solution

As you rightly state, the dashed line indicates a dependency relationship between ConcreteCreator (as the dependent, or client, element) and ConcreteProduct (as the independent, or supplier,element).

In this specific case, the line indicates that ConcreteCreator is responsible for creating instance(s) of ConcreteProduct. This could have been made more clear by attaching the 'create' stereotype to the dependency.

OTHER TIPS

The broken line/empty arrow head denotes a dependency, meaning that ConcreteCreator "uses" ConcreteProduct in some way. The arrow itself doesn't define the nature of that dependency, only that a dependency exists and that ConcreteProduct is not actually a member of the ConcreteCreator.

The provided note (i.e., "return new ConcreteProduct") implies that ConcreteCreator will be instantiating (or creating) objects of type ConcreteProduct, which is natural for a factory. Traditionally in UML, you could clarify this relationship by writing "<<creates>>" over the dashed arrow. UML calls these notes "stereotypes."

See Allen Holub's UML Quick Reference for more information. You can see he has a very similar example where "Users" create "Resources".

I think it means that a ConcreteCreator has to know what a ConcreteProduct is to create it, so there's an explicit dependency there. The factory method creates a Product, but the ConcreteCreator override of that method has to return a ConcreteProduct.

This isn't just the Factory Method - this looks more like the Abstract Factory Pattern. A specific concrete derived class of Creator will create a corresponding instance of a derived Product class.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top