1 / 14

TK2023 Object-Oriented Software Engineering

TK2023 Object-Oriented Software Engineering. CHAPTER 11 CLASS DIAGRAMS. INTRODUCTION. UML provides class diagrams for illustrating classes, interfaces and their associations. Class diagrams are used for static object modelling.

giona
Download Presentation

TK2023 Object-Oriented Software Engineering

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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. Sale Domain Model Register Captures 1 1 time conceptual ... isComplete : Boolean perspective / total Register Sale Design Model time ... 1 isComplete : Boolean DCD ; design endSale () currentSale / total perspective enterItem (...) makeLineItem (...) makePayment (...)

  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. Register Sale 1 ... ... currentSale ... ... • 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

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

  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. Circle Rectangle length : int height : int radius : int ... ... INHERITANCE • Inheritance relationships between a superclass and its subclasses can be expressed in a class diagram as shown below. Shape #colour : Colour ...

  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) Vehicle ... ... Workshop ... ... 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.

More Related