Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

UML representation when hiererachy objects are involved

 
Ashu Sharma
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,
Maybe a dumb UML question but i have got stumped

I have got class A that is composed of the classes B1 and B2 which extend from class B.
The composition rules are different for B1 and B2.

For A to B1 it is 1..* relationship whereas for A to B2 it is 1..1 relationship.

How do i show it UML..

If i show as in figure 1 it does not give the right picture. If i show as in figure 2 it somehow does not look right(i might be wrong on this)

Please help me find the correct representation.

Thanks
Ashu
classes_11.GIF
[Thumbnail for classes_11.GIF]
 
Kazimierz Trzonek
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have another question about class diagram, how do we show relationship between a SampleController class that uses a SampleService class that is implemented by SampleServiceImpl, and SampleServiceImpl uses GenericDao<Sample> interface that is implemented by GenericDaoImpl<Sample> ?

can service be connected with dao by aggregation? (dao is part of service?)
or aggretation is used only to domain classes?

can we use any 'arrow' here? in which direction?
or we simply represent them as properties?

 
Ashu Sharma
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys any suggestions..?
 
Vj Borkar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So assuming that class A holds B1 and B2 and does not know about existence of class B - Figure one is wrong.
If the class A does not know about class B, figure two is wrong too. You will need to remove the aggregation relation between class A and class B.


Ashu Sharma wrote:Hi Ranchers,
Maybe a dumb UML question but i have got stumped

I have got class A that is composed of the classes B1 and B2 which extend from class B.
The composition rules are different for B1 and B2.

For A to B1 it is 1..* relationship whereas for A to B2 it is 1..1 relationship.

How do i show it UML..

If i show as in figure 1 it does not give the right picture. If i show as in figure 2 it somehow does not look right(i might be wrong on this)

Please help me find the correct representation.

Thanks
Ashu
 
Ashu Sharma
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vj,
A has the knowledge about existence of B.If we talk in terms of implementation then it would be something like this in A , so A is aware of B

B b[] = new B1()
B b = new B2()




Thanks
Ashu
 
Ashu Sharma
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ranchers,
Please help me to understand this.
Even if this is a dumb question please let me know that this is dumbest question and can't have any answer.
I am sure your answers to this question will benefit lot of people other than myself.

Thanks
Ashu
 
Ashu Sharma
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any suggestion guys..
 
jon tren
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Class diagrams are supposed to show only static relationships. So Figure 1 seems correct.

 
Janis Kazakovs
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ashu,

The association describes a property of a class, i.e. type of a property, multiplicity relationship and etc.

In your example, you have two properties belonging to the class A, i.e.


B b[] = new B1()
B b = new B2()


These two properties have the same type ( B ), but different multiplicity relationships. As a result, on your class diagram you will show two associations between class A and class B with different multiplicities. You do not need to show the association relationship between two implementation classes of class B, since these are not the types of your properties.

Janis
 
Ashu Sharma
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Janis,
Thanks for your clarification.
It has helped me a lot.


Thanks
Ashu
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic