Suppose I want to draw a class diagram of a DAO and an Entity. The DAO is used to load instances of the Entity from the database. How can I represent this relationship on my class diagram? Is this considered one? I think it should be displayed on the diagram somehow:
enter image description here
TL;DR: should I draw something between them or not?
-
The GOF patterns are often illustrated by UML examples, for your case look here en.wikipedia.org/wiki/Command_pattern, en.wikipedia.org/wiki/Proxy_pattern, en.wikipedia.org/wiki/Abstract_factory_patternDoc Brown– Doc Brown2013年09月18日 18:13:58 +00:00Commented Sep 18, 2013 at 18:13
2 Answers 2
DAO loads data from DB and CREATES instances of Entity:
enter image description here
There is a special stereotype for such dependency. Class INSTANTIATES Class2, if it creates its instances. Exists in UML standard. ( I checked 2.4.1 - contemporary and 2.5 - the next one.)
-
how does this answer the question asked?gnat– gnat2014年01月27日 14:43:29 +00:00Commented Jan 27, 2014 at 14:43
-
DAO loads data from DB and CREATES instances of Entity. It is EXACTLY the answer for the question.Gangnus– Gangnus2014年01月27日 14:44:58 +00:00Commented Jan 27, 2014 at 14:44
-
@gnat Should we really repeat the question in the answer?Gangnus– Gangnus2014年01月27日 14:58:17 +00:00Commented Jan 27, 2014 at 14:58
-
in this case yes, since question title missed the key point addressed by your answergnat– gnat2014年01月27日 15:14:55 +00:00Commented Jan 27, 2014 at 15:14
The closest I can think of is a usage relationship. Possible stereotypes: "use", "call", "create", "instantiate", "send".
SomeDAO ---<<use>>---> SomeEntity