UML Class Diagrams.

Slides:



Advertisements
Similar presentations
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 12Slide 1 Software Design l Objectives To explain how a software design may be represented.
Advertisements

CS 340 UML Class Diagrams. A model is an abstraction of a system, specifying the modeled system from a certain viewpoint and at a certain level of abstraction.
Together and UML Greg Johnson CSE 230 – Software Engineering Spring 2007.
Chapter 15: System Modeling with UML
1 Software Testing and Quality Assurance Lecture 12 - The Testing Perspective (Chapter 2, A Practical Guide to Testing Object-Oriented Software)
UML – Class Diagrams.
Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 1 UML First Pass: Class Diagrams Battery load()
Unified Modeling Language (UML) Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
7M701 1 Class Diagram advanced concepts. 7M701 2 Characteristics of Object Oriented Design (OOD) objectData and operations (functions) are combined 
Unified Modeling Language (UML)
Unified Modeling Language
Object-Oriented Design. From Analysis to Design Analysis Artifacts –Essential use cases What are the problem domain processes? –Conceptual Model What.
CIT241 Prerequisite Knowledge ◦ Variables ◦ Operators ◦ C++ Syntax ◦ Program Structure ◦ Classes  Basic Structure of a class  Concept of Data Hiding.
Object-Oriented Analysis and Design An Introduction.
Conquering Complex and Changing Systems Object-Oriented Software Engineering Chapter 2, Modeling with UML.
UML Diagrams: Class Diagrams The Static Analysis Model Instructor: Dr. Hany H. Ammar Dept. of Computer Science and Electrical Engineering, WVU.
Copyright 2002 Prentice-Hall, Inc. Chapter 2 Object-Oriented Analysis and Design Modern Systems Analysis and Design Third Edition Jeffrey A. Hoffer Joey.
Lab 04.
Modeling Shari L. Pfleeger and Joanne M. Atlee, Software Engineering: Theory and Practice, 4 th edition, Prentice Hall, Hans Van Vliet, Software.
CS3773 Software Engineering Lecture 04 UML Class Diagram.
Unit 1 INTRODUCTION TO MODELING AND CLASS MODEL Ref : L7-UML.PDF.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 14 Slide 1 Object-oriented Design.
1 Class Diagrams: Advanced Concepts. 2 Overview Class diagrams are the most commonly used diagrams in UML. Class diagrams are the most commonly used diagrams.
The Static Analysis Model Class Diagrams Prof. Hany H. Ammar, CSEE, WVU, and Dept. of Computer Science, Faculty of Computers and Information, Cairo University.
Fall 2010 CS4310 Requirements Engineering A Brief Review of UML & OO Dr. Guoqiang Hu Department of Computer Science UTEP 1.
Domain Model Classes and Objects Association Structure Requirement Specification Domain Model.
Introduction To OOP 1.0 Fundamentals Of Java Programming Language 2.0 Exception Handling 3.0 Classes, Inheritance And Polymorphism © 2011 | PN AZRINA.
UML The Unified Modeling Language A Practical Introduction Al-Ayham Saleh Aleppo University
CS 772: Global Knowledge Networks V. “Juggy” Jagannathan CSEE, West Virginia University.
Design Model Lecture p6 T120B pavasario sem.
Object-Oriented Modeling: Static Models. Object-Oriented Modeling Model the system as interacting objects Model the system as interacting objects Match.
Ch- 8. Class Diagrams Class diagrams are the most common diagram found in modeling object- oriented systems. Class diagrams are important not only for.
COP 3331 OBJECT-ORIENTED ANALYSIS AND DESIGN Bob Myers Department of Computer Science.
Class Diagrams. Terms and Concepts A class diagram is a diagram that shows a set of classes, interfaces, and collaborations and their relationships.
Object Oriented Programming and Data Abstraction Earl Huff Rowan University.
1 More About UML Todd Bacastow Penn State University Geospatial System Analysis & Design.
UML. Model An abstract representation of a system. Types of model 1.Use case model 2.Domain model 3.Analysis object model 4.Implementation model 5.Test.
WELCOME TO OUR PRESENTATION UNIFIED MODELING LANGUAGE (UML)
Inf 43: Introduction to Software Engineering May 7, 2016.
Modeling with UML – Class Diagrams
Design Review.
Unified Modeling Language (UML)
UML Diagrams: Class Diagrams The Static Analysis Model
Case Study -- Weather system
Chapter 7 – Object-Oriented Design
Unified Modeling Language
Copyright © 2014 Hassan Gomaa and Robert Pettit
Object-Oriented Analysis and Design
CS410 – Software Engineering Lecture #17: UML I
Unified Modeling Language
Chapter 2, Modeling with UML
Introduction to Unified Modeling Language (UML)
OO Domain Modeling With UML Class Diagrams and CRC Cards
UML - Unified Modeling Language
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
ER MODEL Lecture 3.
UML Unified Modelling Language
Object Oriented Analysis and Design
Seminar 3 UML Class Diagram.
Unified Modeling Language
University of Houston-Clear Lake
UML Class Diagram.
Entity – Relationship Model
Unified Modelling Language
MIS2502: Data Analytics Relational Data Modeling
Analysis models and design models
Systems Analysis – ITEC 3155 Modeling System Requirements – Part 2
Copyright 2007 Oxford Consulting, Ltd
Class Diagrams Class diagram is basically a graphical representation of the static view of the system and represents different aspects of the application.
MIS2502: Data Analytics Relational Data Modeling 2
Presentation transcript:

UML Class Diagrams

Unified Modeling Language (UML) Set of MANY (visual) modeling techniques use case diagram class diagram object diagram component diagram deployment diagram sequence diagram collaboration diagram statechart diagram activity diagram Only 20% are necessary to represent 80% of most systems Static Views Dynamic Views

Unified Modeling Language (UML) Set of MANY (visual) modeling techniques use case diagram class diagram object diagram component diagram deployment diagram sequence diagram collaboration diagram statechart diagram activity diagram Only 20% are necessary to represent 80% of most systems Static Views Dynamic Views

Historical Note: Entity Relationship Diagrams name age student gender entities n student ID enrolled in attributes relationship between entities m subject class course ID max-enroll 4

Class Diagrams Entity Relationship SimpleWatch 1 1 1 1 2 1 2 1 PushButton state push() release() LCDDisplay Battery load() Time now() blinkIdx blinkSeconds() blinkMinutes() blinkHours() stopBlinking() referesh()

Class Diagrams - Entities Entities are abstractions of elements with common characteristics; at the finest-grained level they correspond to classes Entities have three basic components: Name Attributes Operations zone2price getZones() getPrice() TariffSchedule Name Attributes Operations Instance zone2price = { {‘1’, .20}, {‘2’, .40}, {‘3’, .60}} tariff_1974:TarifSchedule

Relationships Between Classes Classes are related to each other via: Generalization Association Aggregation

Generalization Generalization is implemented via “Inheritance” Children inherit attributes and operations of parent; the parent “generalizes” attributes and operations that apply to the children Generalization eliminates redundancy, and supports incrementality

Associations Associations are relations between entities, and can be named Endpoints can note “multiplicity constraints” Potential multiplicity values: 1 0..1 0..n 1..n * 1..*

Aggregation Aggregation is a special case of an association, and defines a “part of” relationship The aggregate is a parent class, the components are children classes Multiplicity can be used here too Exhaust System Part-Of 1 0..2 Muffler Tailpipe 34

Mapping to Ghezzi’s Terms Inheritance, Association, and Aggregation are all forms of USES Representation of IS_COMPONENT_OF is done via the package notation

Packages Organize classes into packages to simplify complex class diagrams A package is a collection of logically related UML elements.

Entities (Expanded) Person + name : String - ssn : String Visibility + public # protected - private Person + name : String - ssn : String # birthday : Date age : int +getName : String -calculateAge : int Visibility AttributeName:Type = Initial Value Visibility MethodName (Parameter List) : Return-List Protected = visible to classes that are inherited from this one

Visibilities Public (+): Any outside class can use the feature (method or data) Private (-): Only the class itself can use the feature Protected (#): Any descendant of the class can use the feature (pertains to the generalization relationship)

Aggregation (Expanded) Simple Aggregation Composite Aggregation With composite aggregation, the part objects may belong to only one whole, and are expected to live and die with the whole.

Self-relations manages employee

Navigabilities Bi-Directional Navigability: An Order has a responsibility to tell me which Customer it is for, and a Customer has a responsibility to tell me which Orders it has. Customer Order ID Date price Name Address Ordered by *  1  Uni-Directional Navigability: An Order has a responsibility to tell me which Customer it is for, but a Customer has no responsibility to tell me which Orders it has. Customer Order ID Date price Name Address Ordered by *  1 

Navigabilities Some people choose to interpret an association edge with no navigability arrows on it as being Bi-directional. Others choose to interpret such an edge as saying that navigability is not yet specified. The latter interpretation facilitates the specification of conceptual models; navigabilities can be added when we move to the specification/implementation models.

Association Classes Book Patron Checks Out Association Class are attributes of relationships between classes; there can be only one instance of the association class between any two participating objects Association Class

Levels of Class Diagrams Conceptual perspective – represents concepts in the domain under study Specification perspective – adds interfaces into the picture; what do classes export? How are associations kept track of? Implementation perspective – adds other elements An incremental refinement process moves you from the first to the last We start with initial analysis to create a high-level conceptual or domain model of the application. This typically contains just classes and maybe a few attributes. At the specification level, we complete all the major attributes, the public methods and understand the class relationships and their cardinalities. At the implementation level, we have translated all the relationships and cardinalities to data structures, and have identified additional classes necessary for implementation.

Constructing Class Diagrams Identify objects Construct conceptual perspective – concepts in the domain under study Refine to specification perspective – add interfaces into the picture and specify relationships more precisely Refine to implementation perspective – add other elements We start with initial analysis to create a high-level conceptual or domain model of the application. This typically contains just classes and maybe a few attributes. At the specification level, we complete all the major attributes, the public methods and understand the class relationships and their cardinalities. At the implementation level, we have translated all the relationships and cardinalities to data structures, and have identified additional classes necessary for implementation.

Object Identification No “magic formula” It relies on the skill, experience and domain knowledge of system designers Iterative process. Unlikely to get it right first time Approaches for identification Use a grammatical approach Identify tangible things Identify objects based on participation in behaviours Use a scenario-based analysis Use domain knowledge for refinement

Library Checkout System: Conceptual Level Patron Book Checks Out id name age isbn title author outDate returned fines

From Conceptual Level to Specification Level Book Patron Book Checks Out id name age isbn title author outDate returned fines Author isbn:string title:string name:string written by 1..5 * 1 Patron BookCopy id:int name:string age:int 1 0..5 copy_num : int 1..* represented by Checks Out outDate:date returned:date fines:currency

From Specification Level to Implementation Level Book Author #isbn:string #title:string #name:string written by 1..5 * Author Book #isbn:string #title:string #writtenby[5]: Author #name:string # writtenby :List<Book>

From Implementation Level to Code Author public class Author { protected: std::string name; std::list<Book> writtenby; } public class Book { std::string isbn; std::string title; Author writtenby[5]; #name:string # writtenby :List<Book> Book #isbn:string #title:string #writtenby[5]: Author

Class Diagram Hints Use initially to provide an abstraction of the problem domain, then refine further Keep a clear separation between specification and implementation Keep them understandable Beware of cyclical generalization Use associations where there are relationships

Example: Simple Online Bookstore Customers search for and select books, order them, provide credit card information to pay for them, and provide delivery information. Information on valid sales (sales for which the credit card is approved) is forwarded to a warehouse where ordered books are collected and shipped. Invalid sales are declined.

Examples of Class Diagram www.uml-diagrams.org http://www.uml-diagrams.org/class-diagrams-examples.html e.g., http://www.uml-diagrams.org/examples/online-shopping-domain-uml-diagram-example.html?context=cls-examples e.g., http://www.uml-diagrams.org/android-camera-uml-class-diagram-example.html