UML Class Diagrams. Represent the (static) structure of the system GeneralIn JavaIn C++ NameNameName StateVariablesMembers BehaviorMethodsFunctions.

Slides:



Advertisements
Similar presentations
1 Object-oriented design Part 2: OO tools & UML. 2 CRC cards Design tool & method for discovering classes, responsibilities, & relationships Record on.
Advertisements

Visual Basic: An Object Oriented Approach 2 – Designing Software Systems.
UML Class and Sequence Diagrams Violet Slides adapted from Marty Stepp, CSE 403, Winter 2012 CSE 403 Spring 2012 Anton Osobov.
UML Class Diagram and Packages Written by Zvika Gutterman Adam Carmi.
UML Class Diagram. UML Class Diagrams2 Agenda What is a Class Diagram? Essential Elements of a UML Class Diagram Tips.
Object-Oriented Analysis and Design
Lecturer: Sebastian Coope Ashton Building, Room G.18 COMP 201 web-page: Lecture.
1 Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 8.1 – 8.5.
UML Class Diagram and Packages Written by Zvika Gutterman Adam Carmi.
Design Patterns in Java Appendix D UML at a Glance Summary prepared by Kirk Scott 1.
UML Class Diagram and Packages
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.
7M701 1 Class Diagram advanced concepts. 7M701 2 Characteristics of Object Oriented Design (OOD) objectData and operations (functions) are combined 
UML: Unified Modeling Language L. Grewe History Graphic modeling language for describing object-oriented software Graphic modeling language for describing.
 2008 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
CMSC 132: Object-Oriented Programming II
Unified Modeling Language (UML)
UML Examples Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
ACM/JETT Workshop - August 4-5, 2005 UML Modeling using MagicDraw UML for Java Programmers.
UML Class Diagrams: Basic Concepts. Objects –The purpose of class modeling is to describe objects. –An object is a concept, abstraction or thing that.
Unified Modeling Language
Unified Modeling Language
Object-Oriented Analysis and Design
UML Diagrams Computer Science I.
 2008 Pearson Education, Inc. All rights reserved (Optional) Software Engineering Case Study: Identifying the Classes in the ATM Requirements.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 2: Modelling.
Software Construction Lecture 5 Class Diagrams. Agenda 2  Topics:  Examples of class diagrams  Navigation, visibility, named associations, and multiplicity.
UML Diagrams: Class Diagrams The Static Analysis Model Instructor: Dr. Hany H. Ammar Dept. of Computer Science and Electrical Engineering, WVU.
UML DIAGRAMS Unified Modeling Language for Object Oriented Programming Unified Modeling Language for Object Oriented Programming.
1 UML Basic Training. UML Basic training2 Agenda  Definitions: requirements, design  Basics of Unified Modeling Language 1.4  SysML.
Lab 04.
Distributed Java Programming Distributed Java Programming Class #2 August 22, 2002.
CS3773 Software Engineering Lecture 04 UML Class Diagram.
Databases : Data Modeling 2007, Fall Pusan National University Ki-Joune Li.
Unit 1 INTRODUCTION TO MODELING AND CLASS MODEL Ref : L7-UML.PDF.
بسم الله الرحمن الرحيم ” اللهم أنت ربي لا إله إلا أنت خلقتني و أنا عبدك وأنا على عهدك ووعدك ما استطعت ، أعوذ بك من شر ما صنعت ، أبوء لك بنعمتك على و أبوء.
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.
UML Diagrams: The Static Model Class Diagrams. The Static Model Define the static structure of the logical model Represent classes, class hierarchies.
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.
© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1 Advanced UML Class Diagrams.
UML Class Diagrams 1 These lecture slides are copyright (C) Marty Stepp, They may not be rehosted, sold, or modified without expressed permission.
Software Design Software Design (UML) Static Modeling using the Unified Modeling Language (UML) Material based on [Booch99, Rambaugh99, Jacobson99, Fowler97,
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.
Class Diagram. Classes Software Design (UML) Class Name attributes operations A class is a description of a set of objects that share the same attributes,
Appendix D UML at a Glance Summary prepared by Kirk Scott 1.
Repetition af Domæne model. Artifact influence emphasizing the Domain Model.
 Week08.  Review Schedule Weeks 8-14  This week o Review last class o Introduce Class Diagrams o ICE-03 Sheridan SYST Engineering Quality Systems.
CSE 403, Spring 2008, Alverson Using UML to express Software Architecture.
Class Diagram Chapter 21 Applying UML and Patterns Craig Larman.
Chapter 3 Class Diagrams. 2 Outline Class Basics Class Basics Classes Classes Association Association Multiplicity Multiplicity Inheritance Inheritance.
Chapter 3: Introducing the UML
Object Modeling THETOPPERSWAY.COM. Object Modelling Technique(OMT)  Building a model of an application domain and then adding implementation.
Class Diagram Lecture # 1. Class diagram A Class Diagram is a diagram describing the structure of a system shows the system's classes Attributes operations.
Introduction to Unified Modeling Language (UML) By Rick Mercer with help from The Unified Modeling Language User Guide, Grady Booch, James Rumbaugh, Ivar.
UML CSE 470 : Software Engineering. Unified Modeling Language UML is a modeling language to express and design documents, software –Particularly useful.
Chapter 12 – Object-Oriented Design
Unified Modeling Language (UML)
UML Diagrams: Class Diagrams The Static Analysis Model
Lec-4 : Unified Modeling Language (UML)
Unified Modeling Language
UML Class Diagrams: Basic Concepts
UML Diagrams: The Static Model Class Diagrams
Basic know how ???.
Domain Class Diagram Chapter 4 Part 2 pp
Software Engineering Lecture #11.
Unified Modelling Language
Object Oriented System Design Class Diagrams
Presentation transcript:

UML Class Diagrams

Represent the (static) structure of the system GeneralIn JavaIn C++ NameNameName StateVariablesMembers BehaviorMethodsFunctions

Relationships Between Classes Association Permanent, structural, “has a” Solid line (arrowhead optional) Aggregation Permanent, structural, a whole created from parts Solid line with diamond from whole Dependency Temporary, “uses a” Dotted line with arrowhead Generalization Inheritance, “is a” Solid line with open (triangular) arrowhead Implementation Dotted line with open (triangular) arrowhead OR

Association Denotes permanent, structural relationship State of class A contains class B Represented by solid line (arrowhead optional) Car and Engine classes know about each other

Associations w/ Navigation Information Can indicate direction of relationship Represented by solid line with arrowhead Gas Pedal class knows about Engine class Engine class doesn’t know about Gas Pedal class

Associations w/ Navigation Information Denotes “has-a” relationship between classes “Gas Pedal” has an “Engine” State of Gas Pedal class contains instance of Engine class  can invoke its methods

Multiplicity of Associations Some relationships may be quantified Multiplicity denotes how many objects the source object can legitimately reference Notation *  0, 1, or more 5  5 exactly 5..8  between 5 and 8, inclusive 5..*  5 or more

Multiplicity of Associations Many-to-one Bank has many ATMs, ATM knows only 1 bank One-to-many Inventory has many items, items know 1 inventory

Aggregation and Composition A special kind of association Models whole-part relationship between things Whole is usually referred to as composite

Composite aggregation Also referred to as composition Composite solely owns the part and they are in a tree structure parts hierarchy Most common form of aggregation In UML, represented by filled diamond Hand Finger

Shared Aggregation Part may be in many composite instances In UML, represented as hollow diamond Network NodeArc

How to identify aggregation Lifetime of part is bound within lifetime of composite There is a create-delete dependency There is an obvious whole-part physical or logical assembly Some properties of composite propagate to parts (e.g., location) Operations applied to composite propagate to parts (e.g., destruction, movement, recording)

Why show aggregation Clarifies domain constraints regarding part- whole relationship Assists in identification of a creator Operations applied to whole should usually propagate to parts Identifying whole wrt a part supports encapsulation

Dependency Denotes dependence between classes Always directed (Class A depends on B) Represented by dotted line with arrowhead A depends on B AB

Dependency Caused by class methods Method in Class A temporarily “uses a” object of type Class B Change in Class B may affect class A A uses object of class B AB

Dependency Dependence may be caused by Local variable Parameter Return value Example Class A {Class B { B Foo(B x) {… B y = new B();… return y;… }} }

Dependency Example Class Driver depends on Class Car

Generalization Denotes inheritance between classes Can view as “is-a” relationship Represented by line ending in (open) triangle Laptop, Desktop, PDA inherit state & behavior from Computers

Implementation Denotes class implements Java interface Represented by dotted line ending in (open) triangle A implements interface B A«B»«B»

UML Examples Read UML class diagram Try to understand relationships Examples Pets & owners Computer disk organization Banking system Home heating system Printing system

UML Example – Veterinary System Try to read & understand UML diagram

UML Example – Veterinary System Try to read & understand UML diagram 1 or more Pets associated with 1 PetOwner

UML Example – Computer System Try to read & understand UML diagram

UML Example – Computer System Try to read & understand UML diagram 1 CPU associated with 0 or more Controllers 1-4 DiskDrives associated with 1 SCSIController SCSIController is a (specialized) Controller

UML Example – Banking System Try to read & understand UML diagram

UML Example – Banking System 1 Bank associated with 0 or more Accounts Checking, Savings, MoneyMarket are Accounts

UML Example – Home Heating System Try to read & understand UML diagram

UML Example – Home Heating System Each Thermostat has 1 Room Each Thermostat associated with 0 or more Heaters ElectricHeater is a specialized Heater AubeTH101D is a specialized Thermostat

UML Class Diagrams  Java Different representation of same information Name, state, behavior of class Relationship(s) between classes Practice deriving one from the other Accurately depicting relationship between classes

UML  Java : Veterinary System UML Java

UML  Java : Veterinary System UML Java class Pet { PetOwner myOwner;// 1 owner for each pet } class PetOwner { Pet [ ] myPets;// multiple pets for each owner }

Java  UML : Veterinary System Java class Pet { PetOwner myOwner;// 1 owner for each pet } class PetOwner { Pet [ ] myPets;// multiple pets for each owner } UML

Java  UML : Veterinary System Java class Pet { PetOwner myOwner;// 1 owner for each pet } class PetOwner { Pet [ ] myPets;// multiple pets for each owner } UML

UML Class Diagrams  Java UML Java class Pet { PetOwner myOwner;// 1 owner for each pet } class PetOwner { Pet [ ] myPets;// multiple pets for each owner }

UML  Java : Computer System UML Java

UML  Java : Computer System UML Java class Controller { } class SCSIController extends Controller { }

UML  Java : Computer System UML Java Design code using all available information in UML…

UML  Java : Computer System Java class CPU { Controller [ ] myCtlrs; } class Controller { CPU myCPU; } class SCSIController extends Controller { DiskDrive [ ] myDrives = new DiskDrive[4]; } Class DiskDrive { SCSIController mySCSI; }

Java  UML : Printing System Java class Registry { PrintQueue findQueue(); } class PrintQueue { List printJobs; Printer myPrinter; Registry myRegistry; void newJob(); int length(); Resources getResource(); }

Java  UML : Printing System Java Class Printer { Resources myResources; Job curJob; void print(); boolean busy(); boolean on(); } class Job { Job(Registry r) { … }

Java  UML : Printing System

UML Summary Graphics modeling language Visually represents design of software system Focus: Class diagrams Contents of a class Relationship between classes You should be able to Draw UML class diagram given code Write code given UML class diagram