#OOP_D_ITS - 8th - Class Diagram

1,358 views

Published on

Published in: Health & Medicine, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,358
On SlideShare
0
From Embeds
0
Number of Embeds
9
Actions
Shares
0
Downloads
81
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

#OOP_D_ITS - 8th - Class Diagram

  1. 1. C++ OOP :: Class Diagram<br />28/10/2009<br />1<br />Hadziq Fabroyir - Informatics ITS<br />
  2. 2. Class<br />a description of a group of objects with similar properties, common behavior, and common semantics.<br />28/10/2009<br />Hadziq Fabroyir - Informatics ITS<br />2<br />
  3. 3. Class<br />a template for instantiation of objects<br />Contains:an attribute (state) section and a method (behavior) section<br />28/10/2009<br />Hadziq Fabroyir - Informatics ITS<br />3<br />
  4. 4. Attribute<br />28/10/2009<br />Hadziq Fabroyir - Informatics ITS<br />4<br />visibilityopt &lt;&lt;sterotype&gt;&gt;optname multiplicityopt : typeopt = initial-valueopt {property-string}opt<br />Example:Tagged value e.g.Author = Kari<br />E.g. &lt;&lt;unique&gt;&gt;<br />- (private) only the class can see<br /> this attribute<br /># (protected) only the class and <br /> all of its subclasses<br />+ (public) all classes that can see<br /> the class can also see<br /> the attribute <br />Example: email[1..*] :String<br />Indicating one or more email addresses.<br />If no email is present you will still have a <br />the empty string (””).If email[0..*] : String is specified, the email<br />can be null.<br />
  5. 5. visibilityopt &lt;&lt;sterotype&gt;&gt;optname(parameter-list) multiplicityopt : return-typeopt {property-string}opt<br />Method<br />28/10/2009<br />Hadziq Fabroyir - Informatics ITS<br />5<br />Examples:+ &lt;&lt;query&gt;&gt; getX() : double+ setX (newX : double)<br />
  6. 6. Class Stereotypes<br />28/10/2009<br />Hadziq Fabroyir - Informatics ITS<br />6<br />
  7. 7. Robustness Diagram Rules<br />28/10/2009<br />Hadziq Fabroyir - Informatics ITS<br />7<br />
  8. 8. The Three Most Important Relationships In Static Modeling<br />28/10/2009<br />Hadziq Fabroyir - Informatics ITS<br />8<br />Base<br />sub<br />Class2<br />Class1<br />Class2<br />Class1<br />Generalization<br />Association<br />Dependency<br />
  9. 9. Generalization <br />Also called generalization/specialization.<br />Example: birds are animals, were birds are the most specialized and animals the most general.<br />28/10/2009<br />Hadziq Fabroyir - Informatics ITS<br />9<br />
  10. 10. Generalization used in class diagrams<br />28/10/2009<br />Hadziq Fabroyir - Informatics ITS<br />10<br />superclass<br />Animal<br />generalization arrow<br />subclass<br />subclass<br />Bird<br />
  11. 11. Association<br />A relationship that describes a set of links between classes of objects, indicating some sort of connection between objects of the involved classes. <br />Example: student follows a course. <br />you can distinguish between ordinary association, simple aggregation and composition(strong aggregation).<br />28/10/2009<br />Hadziq Fabroyir - Informatics ITS<br />11<br />
  12. 12. Simple Aggregation & Ordinary Association<br />It seems difficult to give a formal definition of the distinction between the two concepts.<br />Ordinary association is used when both of the involved classes are equaly important.<br />If there is a part-of relation between the involved classes, then aggregation may be adequate. The question of using association or simple aggregation is a conceptual one, it does not say anything about navigation direction and no connection between lifetime is made.<br />28/10/2009<br />Hadziq Fabroyir - Informatics ITS<br />12<br />
  13. 13. Association used in Class Diagram<br />28/10/2009<br />Hadziq Fabroyir - Informatics ITS<br />13<br />aggregation:<br />association:<br />assembly class<br />class 1<br />class 2<br />role-2<br />role-1<br />name direction<br />association:<br />name<br />class 1<br />class 2<br />part class<br />part class<br />
  14. 14. Example<br />28/10/2009<br />Hadziq Fabroyir - Informatics ITS<br />14<br />University<br />Faculty<br />Teacher<br />Institute<br />works for<br />
  15. 15. Composition<br />Composition is a strong type of aggregation indicating that the part object only exist as a part of the assembly class. The part object of an aggregation will be deleted if the assembly object is deleted. An object may be part of only one composite at a time.<br />28/10/2009<br />Hadziq Fabroyir - Informatics ITS<br />15<br />Composition can be represented in to different ways:<br />assembly class<br />assembly class<br />part class<br />part class<br />
  16. 16. 28/10/2009<br />Hadziq Fabroyir - Informatics ITS<br />16<br />Window<br />1<br />Client Area<br />*<br />*<br />0..2<br />ScrollBar<br />0..1<br />Keyboard<br />Mouse<br />Menu<br />Example<br />Component<br />Input Device<br />
  17. 17. Navigability<br /> If you have a Quiz-object, the associated Question-objects can be directly reach from the Quiz-object. You will typically find a reference of each object inside the Quiz-object.<br />28/10/2009<br />Hadziq Fabroyir - Informatics ITS<br />17<br />Quiz<br />Question<br />Direction of navigation<br />1..*<br />*<br />ordinary association<br />classQuiz{<br /> // A list of questions<br /> Question [] questions;<br />....<br />}<br />class Question {<br />// no reference to Quiz<br />....<br />}<br />
  18. 18. Dependency<br />A dependency relationship indicate that a change in one class may effect the dependent class, but not necessarily the reverse.<br />You use dependency when you wants to indicate that one thing uses another.<br />Often used to indicate that a method has object of a class as arguments. <br />28/10/2009<br />Hadziq Fabroyir - Informatics ITS<br />18<br />
  19. 19. Example: Dependency<br />28/10/2009<br />Hadziq Fabroyir - Informatics ITS<br />19<br />ActionListener<br />ActionEvent<br />actionPerformed(ActionEvent e)<br />
  20. 20. Multiplicity<br />28/10/2009<br />Hadziq Fabroyir - Informatics ITS<br />20<br />1<br />1..*<br />A<br />B<br />A<br />B<br />An A is associatedwith exactly one B<br />An A is associatedwith one or more B<br />*<br />0..1<br />A<br />B<br />A<br />B<br />An A is associatedwith zero or more B<br />An A is associatedwith zero or one B<br />The multiplicity is describing the number of participants (classes) involved in an association. For instance an edge in a graph is connecting exactly two vertexes.<br />
  21. 21. 28/10/2009<br />Hadziq Fabroyir - Informatics ITS<br />21<br /> ?<br />End of slide show<br />
  22. 22. For your practice …<br />28/10/2009<br />Hadziq Fabroyir - Informatics ITS<br />22<br />
  23. 23. Ex: undirected graph<br />28/10/2009<br />Hadziq Fabroyir - Informatics ITS<br />23<br />1<br />1<br />*<br />*<br />2<br />*<br />Graph<br />Vertex<br />Edge<br />
  24. 24. Ex: information system for school<br />28/10/2009<br />Hadziq Fabroyir - Informatics ITS<br />24<br />0..1<br />has<br />Department<br />School<br />1<br />1..*<br />1..*<br />1..*<br />1..*<br />member<br />assignedTo<br />0..1<br />chairperson<br />1..*<br />1..*<br />*<br />teaches<br />attends<br />student<br />Course<br />Instructor<br />1..*<br />*<br />*<br />*<br />
  25. 25. ☺~ Next: &lt;Template&gt; ~☺<br />[ 25 ]<br />Hadziq Fabroyir - Informatics ITS<br />28/10/2009<br />

×