Presentation is loading. Please wait.

Presentation is loading. Please wait.

TK2023 Object-Oriented Software Engineering CHAPTER 11 CLASS DIAGRAMS.

Similar presentations


Presentation on theme: "TK2023 Object-Oriented Software Engineering CHAPTER 11 CLASS DIAGRAMS."— Presentation transcript:

1 TK2023 Object-Oriented Software Engineering CHAPTER 11 CLASS DIAGRAMS

2 INTRODUCTION UML provides class diagrams for illustrating classes, interfaces and their associations. Class diagrams are used for static object modelling. Note that class diagrams are also used for visualizing domain models. The term design class diagram (DCD) will be used to refer to the class diagram used in the design perspective (as opposed to the conceptual perspective).

3 Register... endSale() enterItem(...) makePayment(...) Sale time isComplete:Boolean /total makeLineItem(...) Register... Sale time isComplete:Boolean /total Captures 1 1 1 Domain Model conceptual perspective Design Model DCD;design perspective currentSale

4 ATTRIBUTES Attributes of a class can be shown in the attribute text notation. Use this notation for data type objects i.e. objects for which unique identity is not important. Person name : String dob : Date...

5 Attributes of a class can also be shown in the association line notation. Note the following style:  a navigability arrow pointing from the source to the target object  a multiplicity at the target end, but not the source end  a rolename only at the target end to show the attribute name  no association name Register... Sale... 1 currentSale

6 Visibility marks are used to indicate whether an attribute is public, private or protected.  If no visibility is given, attributes are usually assumed private. - owner Car + year : int Person # name : String 1 public attribute private attribute protected attribute

7 When using class diagrams to show domain models:  show association names  avoid navigation arrows

8 OPERATIONS AND METHODS Examples of operations: An operation is assumed public if visibility is not indicated. Rectangle + setLength(int val) + getArea() : int

9 An operation is not a method. In UML, an operation is a declaration whereas a method is its implementation. getter and setter operations are usually filtered out in class diagrams because they generate high noise-to-value ratio. Example:getArea(), setLength(val)

10 INHERITANCE Inheritance relationships between a superclass and its subclasses can be expressed in a class diagram as shown below. Shape #colour : Colour... Rectangle length : int height : int... Circle radius : int...

11 DEPENDENCY RELATIONSHIP A dependency relationship exists between a client element (of any kind, including classes, packages, use cases, etc) and a supplier element if the former has knowledge of the supplier element and that a change in the supplier could affect the client.

12 Example: Suppose the class Workshop has the following operation void addClient(Customer c, Vehicle v) Workshop... Vehicle... Customer...

13 Note that the dependency relationship is a very general one. For example, an inheritance relationship is actually a kind of dependency relationship. Use the guideline below for DCDs: Use the dependency line to show the following types of dependencies between objects:  global  parametric  local

14 RELATIONSHIP BETWEEN INTERACTION AND CLASS DIAGRAMS When interaction diagrams are drawn, a set of classes and their methods emerge from doing dynamic object modelling. This means that definitions of class diagrams can be generated from interaction diagrams. This suggests a linear ordering of drawing interaction diagrams before class diagrams. In practice, these complementary dynamic and static views are drawn concurrently.


Download ppt "TK2023 Object-Oriented Software Engineering CHAPTER 11 CLASS DIAGRAMS."

Similar presentations


Ads by Google