Class Diagram M. Seidl, et al., UML@Classroom, Introduction to Object-Oriented Modeling, Springer, 2015. Chaper 4. Soft copy (pdf) downloadable freely.

Slides:



Advertisements
Similar presentations
UML Class Diagram. UML Class Diagrams2 Agenda What is a Class Diagram? Essential Elements of a UML Class Diagram Tips.
Advertisements

UML Class Diagram and Packages Written by Zvika Gutterman Adam Carmi.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
What is UML? A modeling language standardized by the OMG (Object Management Group), and widely used in OO analysis and design A modeling language is a.
Unified Modeling Language (UML)
Class Diagram & Object Diagram
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 Class and Object Diagrams PRACTICAL OBJECT-ORIENTED DESIGN WITH.
1 Object-Oriented Modeling Using UML CS 3331 Fall 2009.
Object-Oriented Analysis and Design
Chapter 9 Domain Models. Domain Model in UML Class Diagram Notation A “visual dictionary”
CSE314 Database Systems Data Modeling Using the Entity- Relationship (ER) Model Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson Ed Slide Set.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented Design.
UML Diagrams: Class Diagrams The Static Analysis Model Instructor: Dr. Hany H. Ammar Dept. of Computer Science and Electrical Engineering, WVU.
Object-Oriented Software Development F Software Development Process F Analyze Relationships Among Objects F Class Development F Class Design Guidelines.
CS3773 Software Engineering Lecture 04 UML Class Diagram.
University of Toronto Department of Computer Science © Steve Easterbrook. This presentation is available free for non-commercial use with attribution.
Databases : Data Modeling 2007, Fall Pusan National University Ki-Joune Li.
Unit 1 INTRODUCTION TO MODELING AND CLASS MODEL Ref : L7-UML.PDF.
Unified Modeling Language © 2002 by Dietrich and Urban1 ADVANCED DATABASE CONCEPTS Unified Modeling Language Susan D. Urban and Suzanne W. Dietrich Department.
Chapter 16 Applying UML and Patterns Craig Larman
® IBM Software Group © 2006 IBM Corporation Rational Software France Object-Oriented Analysis and Design with UML2 and Rational Software Modeler 03. Classes,
The Static Analysis Model Class Diagrams Prof. Hany H. Ammar, CSEE, WVU, and Dept. of Computer Science, Faculty of Computers and Information, Cairo University.
1 CMPT 275 Software Engineering Requirements Analysis Phase Requirements Analysis activity Janice Regan,
UML Class Diagram Trisha Cummings. What we will be covering What is a Class Diagram? Essential Elements of a UML Class Diagram UML Packages Logical Distribution.
NJIT UML Class Diagrams Chapter 16 Applying UML and Patterns Craig Larman.
Lecture 1: UML Class Diagram September 12, UML Class Diagrams2 What is a Class Diagram? A class diagram describes the types of objects in the system.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved COS240 O-O Languages AUBG,
Class Diagram Classes are the most important building block of any object-oriented system. A class is a description of a set of objects that share the.
Design Model Lecture p6 T120B pavasario sem.
Object Oriented Analysis: Associations. 2 Object Oriented Modeling BUAD/American University Class Relationships u Classes have relationships between each.
Object-Oriented Modeling: Static Models Grady Booch, James Rumbaugh, and Ivar Jacobson, The Unified Modeling Language User Guide, 2 nd edition, Addison.
Chapter 4 Extended Entity-Relationship (EER)Model Incorporates Set-subset Relationships Incorporates Generalization Hierarchies Constraints: Coverage Constraints:
CS212: Object Oriented Analysis and Design Lecture 33: Class and Sequence Diagram.
Chapter 16 UML Class Diagrams 1CS6359 Fall 2012 John Cole.
Chapter 16 UML Class Diagrams.
Object Modeling THETOPPERSWAY.COM. Object Modelling Technique(OMT)  Building a model of an application domain and then adding implementation.
ITEC0724 Modern Related Technology on Mobile Devices Lecture Notes #2 1.
Smith’s Aerospace © P. Bailey & K. Vander Linden, 2006 Classes and Objects Patrick Bailey Keith Vander Linden Calvin College.
Data Modeling Using the Entity- Relationship (ER) Model
UML Diagrams: Class Diagrams The Static Analysis Model
Object-Oriented Modeling
Chapter 9 Domain Models.
UML Class Diagrams (more notation)
Chapter 5: Structural Modeling
Chapter 16 UML Class Diagrams.
Class Diagrams.
Class Diagram M. Seidl, et al., Introduction to Object-Oriented Modeling, Springer, Chaper 4. Soft copy (pdf) downloadable freely.
Chapter 7: Entity-Relationship Model
Entity-Relationship Modelling
Reference: COS240 Syllabus
UML Unified Modelling Language
Object Oriented Analysis and Design
Seminar 3 UML Class Diagram.
Lec 3: Object-Oriented Data Modeling
Software Engineering Lecture #11.
Object Oriented Analysis and Design Using the UML
Module 8 – Database Design Using the E-R Model
2018, Fall Pusan National University Ki-Joune Li
UML Class Diagram.
Chapter 20 Object-Oriented Analysis and Design
Entity-Relationship Modelling
CIS 375 Bruce R. Maxim UM-Dearborn
Unified Modelling Language
Understand and Use Object Oriented Methods
Software Design Lecture : 15.
Objects, Classes, and Basic Class Diagrams
CIS 375 Bruce R. Maxim UM-Dearborn
Object Oriented System Design Class Diagrams
Chapter 6b: Database Design Using the E-R Model
2019, Fall Pusan National University Ki-Joune Li
Presentation transcript:

Class Diagram M. Seidl, et al., UML@Classroom, Introduction to Object-Oriented Modeling, Springer, 2015. Chaper 4. Soft copy (pdf) downloadable freely through UTEP library.

Class Diagram Models data, entities and static structures Most important and most widely-used diagram in UML Central model due to stability (of data), say, compared to functionalities such as use cases. Describes the structure of a system by showing the system's classes, their attributes/operations, and the relationships among the classes

Example: PC Architecture 0..2 0..2 interface IdeDevice Motherboard IdeBus interface ScsiDevice CdRom {abstract} HpCdWriter LaserController

Types of Relationships Construct Notation Association Aggregation Composition Generalization Realization Dependency

Association General binary relationships between classes Commonly represented as direct or indirect references between classes Student Course

Association Details Can express the following optional information Association name (e.g., enroll) Navigability (e.g., ->) Multiplicity (e.g., 10..*) Role names (e.g., course) 1 2 enroll Student Course 10..* course 3 4

Association Name May have an optional label consisting of a name and a direction drawn as a solid arrowhead with no tail. The direction arrow indicates the direction of association with respect to the name, i.e., the direction in which the name should be read. Use a verb or verb phrase. advise Faculty Student

Navigability An arrow may be attached to the end of path to indicate that navigation is supported in that direction. advise Faculty X Student

Multiplicity Optional multiplicity specification defining the number of objects that can participate in an instantiated relation On one or both association ends The multiplicity specifies an integer interval, e.g., l..u closed (inclusive) range of integers i singleton range 0..* entire nonnegative integer, i.e., 0, 1, 2, … advise 1 0..* Faculty Student

Role Names Optional role name on one or both association ends Use a noun or noun phrase describing the semantics of the role. advise 1 0..* Faculty Student advisor advisees

Exercise Write skeletal Java code conforming to the following model. 10..* enroll 0..* Student Course 1..3 0..* taught instructor 1 advised 1 Faculty advisor

Aggregation Special form of association representing has-a or part-whole relationship. Distinguishes the whole (aggregate class) from its parts (component class). No relationship in the lifetime of the aggregate and the components (can exist separately). Aggregate Component

Composition Stronger form of aggregation Implies exclusive ownership of the component class by the aggregate class The lifetime of the components is entirely included in the lifetime of the aggregate (a component can not exist without its aggregate). Composition Component

Example University 1..* 1..* 0..* College Department Student chair-of member-of 1 1..* Faculty

Generalization And Realization An extension relation is called specialization and generalization. An implementation relation is called realization. Superclass Superinterface Interface Subclass Subinterface Class extension of classes extension of interfaces implementation of interfaces

Example Student {abstract} Graduate {abstract} Nondegree Undergraduate Master PhD

Dependency Relationship between the entities such that the proper operation of one entity depends on the presence of the other entity, and changes in one entity would affect the other entity. The common form of dependency is the use relation among classes. <<use>> Class1 Class2

Exercise: Strength (Coupling)? Association, aggregation, composition, generalization, realization, and dependency. Weakest Strongest

Class Details The UML notation for classes is a rectangular box with as many as three compartments. Name attribute1 …… attributen operation1 … operationn The top compartment show the class name. The middle compartment contains the declarations of the attributes (fields) of the class. The bottom compartment contains the declarations of the operations (methods) of the class.

Example Attribute type Name of the class Attribute name Student - name: String = “John” {readOnly} - courses: Course [*] + register (c: Course) + isRegistered (c: Course) : Boolean Other Properties Visibility: +, -, #, ~ Default value Multiplicity Operation name Return value Parameters 20 20

Inline vs. Diagram Notation Two ways to express associations Use either one, but not both. 1 Course Instructor Course -instructor: Instructor -students: Student[10..*] -instructor 10..* -students Student

Guidelines Identify important data, entities, and domain concepts List all nouns or noun phrases Determine candidate classes Define relationships among classes Association/aggregation: has-knowledge-of, is-part- of Generalization/realization: is-a relation Define responsibilities of classes (operations) Define internal structures of classes (attributes) Refine, refine, refine …

Exercise Form a pair. Model the Battleship game by drawing a class diagram; focus on the functional core (or business logic), not UI. Assume: A board consists of n*n places (or squares), where n >= 10. A player’s feet consists of 5 ships: aircraft carrier (size 5), battleship (4), frigate (3), submarine (3), and minesweeper (2). Ships can’t overlap when placed on a board.

Sample Solution has_fleet_of Ship isSunk 5 0..1 is_placed_on s: ship size 0, s Game activePlayer changeTurn isWonBy Place hit isHit place_ships 2 1 n*n Player Board 1 pick_place_of ComputerPlayer placeShips 1 Strategy pickPlace

Exercise Any ambiguity or impreciseness in the previous class diagram? Find and list all of them. How to know that the previous diagram is a “correct” or “good” design/model? Refine it by introducing more public operations from the client view point.