Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 11: Class Diagram

Similar presentations


Presentation on theme: "Chapter 11: Class Diagram"— Presentation transcript:

1 Chapter 11: Class Diagram
Chapter 19 in Applying UML and Patterns Book.

2 Overview What is Class Diagram?
The different between Domain Model and Design Model. How to build UML Class Diagram (Class, Attribute, Relationship).

3 What is Class Diagram ? A class diagram shows the existence of classes and their relationships in the logical view of a system. UML modeling elements in class diagrams: Classes and their structure and behavior. Association, aggregation, dependency, and inheritance relationships. Multiplicity and navigation indicators. Role names.

4 Dependency Dependency means “One class uses the other”
A dependency relationship indicates that a change in one class may effect the dependent class, but not necessarily the reverse. A dependency relationship is often used to show that a method has object of a class as arguments. Basic Class Dependent Class Depends on

5 Generalization hierarchy

6 Generalization hierarchy with added detail

7 Domain Model (Conceptual Model) vs
Domain Model (Conceptual Model) vs. Design Model Classes (Class Diagram) (Conceptual Model) (Class Diagram)

8 Example Design Class Diagrams (DCD)

9 Creating NextGen POS DCD
Identify all the classes participating in the software solution. Do this by analyzing the interaction diagrams. Draw them in a class diagram. Duplicate (i.e. copy) the attributes from the associated concepts in the Domain Model.

10 Steps: Design to Code Main goal is to define Design Class Diagram with Attributes and Methods Defining Concepts Adding Reference Attributes, attributes. Creating methods from interaction diagrams: Find & Add methods. Add type information to the attributes and methods Add navigability and associations. Collection classes in code.

11 Creating NextGen POS DCD
Add method names for each class by analyzing the interaction diagrams.

12 Creating Methods from Sequence Diagrams
12 Creating Methods from Sequence Diagrams :Register :ProductCatalogue Sale :SalesLineItem :ProductSpec Constructor 1. Spec=getSpecification(itemID) 1.1 Spec=Find(itemID) 2. makeLineItem(spec,quantity) 2.1 sli= Create(spec,quantity) 2.1.1 Sub=getSubTotal(itemID) 2.2 Add(sli)

13 Creating NextGen POS DCD
Add type information to the attributes and methods.

14 Question: Register – addLineItem Method
The addLineItem sequence diagram will be used to illustrate the Java definition of the addLineItem method. Which class addLineItem should belong to? The addLineItem message is sent to a Register instance, therefore the addLineItem method is defined in class Register. public void addLineItem (itemID itemID, int quantity); Message 1. A getSpecification message is sent to the productCatalog to retrieve a productSpecification. productSpecification spec = catalog.getSpecification (itemID); Message 2. The makeLineItem message is sent to the Sale. sale.makeLineItem (spec, quantity);

15 Register - addLineItem Method
Public void addlineitem(itemid itemid, int quantity) { productSpecification spec = catalog.getSpecification(itemID); sale.makeLineItem(spec, quantity); } Public productSpecification getSpecification(itemID){ spec := find(itemID); Return spec; } Public void makeLineItem (productSpecification spec, int quantity){ sli= create(spec, quantity); //new in java add(sli);

16 Skeletal definition of Register Class

17 Collection Classes in Code

18 Adding Navigability & Dependency Relationships


Download ppt "Chapter 11: Class Diagram"

Similar presentations


Ads by Google