A UML Class Diagram Tutorial

Similar documents
11 November

Using UML Part One Structural Modeling Diagrams

UML Tutorial: Part 1 -- Class Diagrams.

ATM Case Study OBJECTIVES Pearson Education, Inc. All rights reserved Pearson Education, Inc. All rights reserved.

An Introduction To UML Class Diagrams Classes

Object Oriented Software Models

Tutorial - Building a Use Case Diagram

Java (12 Weeks) Introduction to Java Programming Language

Graphical Systems Modeling with UML / SysML Class diagrams

Visio Tutorial 1BB50 Data and Object Modeling (DOM) How to make a UML Class Diagram 2004/2005

Umbrello UML Modeller Handbook

Software Engineering. System Models. Based on Software Engineering, 7 th Edition by Ian Sommerville

History OOP languages Year Language 1967 Simula Smalltalk

CSE 1020 Introduction to Computer Science I A sample nal exam

Canterbury Maps Quick Start - Drawing and Printing Tools

UML Class Diagrams. Lesson Objectives

Glossary of Object Oriented Terms

UML TUTORIALS THE COMPONENT MODEL

Types of UML Diagram. UML Diagrams OOAD. Computer Engineering Sem -IV

LAB 3: Introduction to Domain Modeling and Class Diagram

Florida Department of Education/Office of Assessment January Grade 6 FCAT 2.0 Mathematics Achievement Level Descriptions

How To Design Software

Concepts of Database Management Seventh Edition. Chapter 9 Database Management Approaches

The Business Process Model

Introduction. UML = Unified Modeling Language It is a standardized visual modeling language.

Association - Multiplicity. UML and Classes, Objects and Relationships [ 2] Notes. Notes. Association - Self. Association - Self

Implementation Aspects of OO-Languages

Object Oriented Design

GAP CLOSING. 2D Measurement. Intermediate / Senior Student Book

SemTalk BPMN Tutorial APRIL Tutorial SemTalk 4.3 BPMN Edition for Business Process Analysis

Such As Statements, Kindergarten Grade 8

Design and UML Class Diagrams. Suggested reading: Practical UML: A hands on introduction for developers

7 Relations and Functions

Design and UML Class Diagrams

Chapter 8 The Enhanced Entity- Relationship (EER) Model

BPMN 2.0 Tutorial. Daniel Brookshier Distinguished Fellow No Magic Inc.

Java Interview Questions and Answers

Sources: On the Web: Slides will be available on:

Chapter 2: Entity-Relationship Model. Entity Sets. " Example: specific person, company, event, plant

Data Flow Diagram (DFD) Tutorial Written Date : January 27, 2012

SE 360 Advances in Software Development Object Oriented Development in Java. Polymorphism. Dr. Senem Kumova Metin

How To Understand The Purpose Of A Class Diagram In Java.Io (Java)

Flash Tutorial Part I

Database Design Methodology

Object Oriented Programming. Risk Management

View Controller Programming Guide for ios

Lectures 2 & 3: Introduction to Modeling & UML. Getting started

Doña Ana County, NM Map Help

Course Syllabus For Operations Management. Management Information Systems

Software Project Management and UML

UML FOR OBJECTIVE-C. Excel Software

Realizing Enterprise Integration Patterns in WebSphere

UML Class Diagrams (1.8.7) 9/2/2009

How To Draw A Cell Phone Into A Cellphone In Unminimal Diagram (Uml)

Rose Data Modeler (logical)

Everyday Mathematics CCSS EDITION CCSS EDITION. Content Strand: Number and Numeration

Everyday Mathematics GOALS

WORK SCHEDULE: MATHEMATICS 2007

Analysis and Design with UML

Chapter 2: Entity-Relationship Model. E-R R Diagrams

A Rational Software Whitepaper

Structural Modeling and Analysis

Object-Oriented Analysis & Design

CPS211 Lecture: Class Diagrams in UML

2. Analysis. The goal of this is to understand the problem. The key question is What?.

Decimals and Percentages

Information Technology Solutions

Using UML Part Two Behavioral Modeling Diagrams

How To Understand The Organizational Model Of A Multiagent System

5 Process Modeling using UML

Unit 21 - Creating a Button in Macromedia Flash

Data Flow Diagram (DFD) Tutorial Written Date : January 27, 2012

An eclipse-based Feature Models toolchain

Object-Oriented Databases

DIA Creating Charts and Diagrams

Glencoe. correlated to SOUTH CAROLINA MATH CURRICULUM STANDARDS GRADE 6 3-3, , , 4-9

CPS122 Lecture: State and Activity Diagrams in UML

Johannes Sametinger. C. Doppler Laboratory for Software Engineering Johannes Kepler University of Linz A-4040 Linz, Austria

3SL. Requirements Definition and Management Using Cradle

Practical Programming Methodology. Michael Buro. Class Inheritance (CMPUT-201)

UML basics. Part III: The class diagram. by Donald Bell IBM Global Services

Charlesworth School Year Group Maths Targets

UML Modeling Guidelines

CATIA: Navigating the CATIA V5 environment. D. CHABLAT / S. CARO Damien.Chablat@irccyn.ec-nantes.fr

Introducing Variance into the Java Programming Language DRAFT

PART-A Questions. 2. How does an enumerated statement differ from a typedef statement?

Agenda. What is and Why Polymorphism? Examples of Polymorphism in Java programs 3 forms of Polymorphism

Lab Manual: Using Rational Rose

Hands-On Practice. Using Notebook Software in the Office

Application Note C++ Debugging

Quality Improvement Works on Existing Processes

Number Sense and Operations

SolidWorks. SolidWorks Teacher Guide. and Student Courseware

Fundamentals of Visual Modeling

Calculating Area, Perimeter and Volume

CS 487. Week 8. Reference: 1. Software engineering, roger s. pressman. Reading: 1. Ian Sommerville, Chapter 3. Objective:

Chapter 6: Programming Languages

Unit 1, Lesson 03: Answers to Homework 1, 0, +1 2, 1, 0, +1, +2 1, 0, +1 2, 1, 0, +1, +2 3, 2, 1, 0, +1, +2, +3. n = 3 l = 2 m l = -2 m s = -½

Object Oriented Programming and the Objective-C Programming Language 1.0. (Retired Document)

Welcome to CorelDRAW, a comprehensive vector-based drawing and graphic-design program for the graphics professional.

Transcription:

A UML Class Diagram Tutorial The UML Class diagram is a graphical notation used to construct and visualize object oriented systems. A UML class diagram is made up of: A set of classes and A set of relationships between classes What is a class? A class in an object oriented system provides a crisp abstraction of a well defined set of responsibilities. A class consists of three parts: (Refer to the figure on the right) Class Name: o The name of the class appears in the first partition. Class Attributes: o Attributes are shown in the second partition. o The attribute type is shown after the colon. o Attributes map onto member variables (data members) in code. Class Operations (Methods): o Operations are shown in the third partition. They are services the class provides. o The return type of a method is shown after the colon at the end of the method signature. o The return type of method parameters are shown after the colon following the parameter name. o Operations map onto class methods in code The graphical representation of a Class We can observe the following for MyClassName MyClassName has 3 attributes and 3 operations Parameter p3 of op2 is of type int op2 returns a float op3 returns a pointer (denoted by a *) to Class6 Page 1 of 8

Visibility and Access for attributes and operations of a class The +, - and # symbols before an attribute and operation name in a class denote the visibility of the attribute and operation. + denotes public attributes or operations - denotes private attributes or operations # denotes protected attributes or operations We can observe that attribute1 and op1 of MyClassName are public attribute3 and op3 are protected. attribute2 and op2 are private. Access for each of these visibility types is shown below for members of different classes. Access public (+) private (-) Members of the same class yes yes yes Members of derived classes yes no yes Members of any other class yes no no protected (#) Page 2 of 8

Operation (Method) Parameter Directionality Each parameter in an operation (method) may be denoted as in, out or inout which specifies its direction with respect to the caller. This directionality is shown before the parameter name. These are briefly explained below: Parameter direction Description in states that p1 and p2 are passed to op1 by the caller. They are both in parameters. inout states that p3 is passed to op2 by the caller and is then possibly modified by op2 and is passed back out. p3 is an inout parameter. out states that p6 is not set by the caller but is modified by op3 and is passed back out. p6 is an out parameter. Page 3 of 8

Relationships between classes A class may be involved in one or more relationships with other classes. A relationship can be one of the following types: (Refer to the figure on the right for the graphical representation of relationships) Relationship Type Graphical Representation Inheritance (or Generalization): Represents an is-a relationship. An abstract class name is shown in italics. SubClass1 and SubClass2 are specializations of SuperClass. Association Simple association: o A structural link between two peer classes. o There is an association between Class1 and Class2 Aggregation: A special type of association. It represents a partof relationship. o Class2 is part of Class1. o Many instances (denoted by the *) of Class2 can be associated with Class1. o Objects of Class1 and Class2 have separate lifetimes. Page 4 of 8

Composition: A special type of aggregation where parts are destroyed when the whole is destroyed. o Objects of Class2 live and die with Class1. o Class2 cannot stand by itself. Dependency: o Exists between two classes if changes to the definition of one may cause changes to the other (but not the other way around). o Class1 depends on Class2 Page 5 of 8

A class diagram may also have notes attached to classes or relationships. Notes are shown in grey. An Example The following can be observed from the above diagram: 1. Shape is an abstract class. It is shown in Italics. 2. Shape is a superclass. Circle, Rectangle and Polygon are derived from Shape. In other words, a Circle is-a Shape. This is a generalization / inheritance relationship. 3. There is an association between DialogBox and DataController. 4. Shape is part-of Window. This is an aggregation relationship. Shape can exist without Window. 5. Point is part-of Circle. This is a composition relationship. Point cannot exist without a Circle. 6. Window is dependent on Event. However, Event is not dependent on Window. 7. The attributes of Circle are radius and center. This is an entity class. 8. The method names of Circle are area(), circum(), setcenter() and setradius(). 9. The parameter radius in Circle is an in parameter of type float. 10. The method area() of class Circle returns a value of type double. 11. The attributes and method names of Rectangle are hidden. Some other classes in the diagram also have their attributes and method names hidden. Page 6 of 8

Exercise 1 Consider the following UML Class Diagram snippets. Choose the type of relationship between classes given below. 1. InventoryItem and Book 2. Book and DVD 3. Student and Course Page 7 of 8

4. Student and Schedule 5. ClientDisplay and Supplier 6. Department and Company 7. InventoryItem and DVD Exercise 2: True or False? You can use a dependency relationship to represent precedence, where one model element must precede another. An aggregation is a special type of association in which objects are assembled or configured together to create a more complex object. An association represents a non-structural relationship that connects two classes. A composition association relationship connects a Student class with a Schedule class, which means that if you remove the student, the schedule is also removed. Because child classes in generalizations inherit the attributes, operations, and relationships of the parent, you must only define for the child the attributes, operations, or relationships that are distinct from the parent. True/False Page 8 of 8