11 November 2015. www.isbe.tue.nl. www.isbe.tue.nl



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

Case studies: Outline. Requirement Engineering. Case Study: Automated Banking System. UML and Case Studies ITNP090 - Object Oriented Software Design

UML Class Diagrams. Lesson Objectives

LAB 3: Introduction to Domain Modeling and Class Diagram

An Introduction To UML Class Diagrams Classes

Database Design Methodology

How To Design Software

III. Class and Object Diagrams

Structural Modeling and Analysis

IV. The (Extended) Entity-Relationship Model

Lecturer: Sebastian Coope Ashton Building, Room G.18 COMP 201 web-page:

Tutorial - Building a Use Case Diagram

1 Class Diagrams and Entity Relationship Diagrams (ERD)

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

Object Oriented Design

ATM Case Study Part 1

Using UML Part One Structural Modeling Diagrams

How to Make a Domain Model. Tutorial

2. Conceptual Modeling using the Entity-Relationship Model

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

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

Design and UML Class Diagrams

Object Oriented Software Models

Data Analysis 1. SET08104 Database Systems. Napier University

History OOP languages Year Language 1967 Simula Smalltalk

Getting Started With UML Class Modeling. An Oracle White Paper May 2007

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

Chapter 13 - Inheritance

Unit 2.1. Data Analysis 1 - V Data Analysis 1. Dr Gordon Russell, Napier University

Lesson 8: Introduction to Databases E-R Data Modeling

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

Entity-Relationship Model. Purpose of E/R Model. Entity Sets

Umbrello UML Modeller Handbook

Communication Diagrams

Graphical Systems Modeling with UML / SysML Class diagrams

Software Development: An Introduction

Chapter 2: Entity-Relationship Model

Chapter 8 The Enhanced Entity- Relationship (EER) Model

ER modelling, Weak Entities, Class Hierarchies, Aggregation

Case Study: ATM machine I. Amalia Foka CEID - University of Patras Object Oriented Programming II (C++) Fall

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

Introduction to Object-Oriented Programming

a. Inheritance b. Abstraction 1. Explain the following OOPS concepts with an example

TECH. Requirements. Why are requirements important? The Requirements Process REQUIREMENTS ELICITATION AND ANALYSIS. Requirements vs.

BCS THE CHARTERED INSTITUTE FOR IT. BCS HIGHER EDUCATION QUALIFICATIONS BCS Level 5 Diploma in IT SYSTEMS ANALYSIS & DESIGN EXAMINERS REPORT

Structural Design Patterns Used in Data Structures Implementation

Object-Oriented Design. CSE 5236: Mobile Application Development Course Coordinator: Dr. Rajiv Ramnath Instructor: Adam C.

three Entity-Relationship Modeling chapter OVERVIEW CHAPTER

Glossary of Object Oriented Terms

CSCI 253. Object Oriented Programming (OOP) Overview. George Blankenship 1. Object Oriented Design: Java Review OOP George Blankenship.

Announcements. SE 1: Software Requirements Specification and Analysis. Review: Use Case Descriptions

Object Oriented System Analyze and Design of Revenue Information System using UML

Database Design Overview. Conceptual Design ER Model. Entities and Entity Sets. Entity Set Representation. Keys

Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model

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

Questions? Assignment. Techniques for Gathering Requirements. Gathering and Analysing Requirements

Java (12 Weeks) Introduction to Java Programming Language

A terminology model approach for defining and managing statistical metadata

Object-Oriented Data Modeling

BCS THE CHARTERED INSTITUTE FOR IT BCS HIGHER EDUCATION QUALIFICATIONS BCS Level 5 Diploma in IT. September 2013 EXAMINERS REPORT

Agile Software Development

CS193j, Stanford Handout #10 OOP 3

D06 PROGRAMMING with JAVA. Ch3 Implementing Classes

Software Testing. Definition: Testing is a process of executing a program with data, with the sole intention of finding errors in the program.

Programming Language Constructs as Basis for Software Architectures

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

Why & How: Business Data Modelling. It should be a requirement of the job that business analysts document process AND data requirements

13 Classes & Objects with Constructors/Destructors

An Approach towards Automation of Requirements Analysis

III. Class and Object Diagrams

Analysis and Design with UML

D6 INFORMATION SYSTEMS DEVELOPMENT. SOLUTIONS & MARKING SCHEME. June 2013

Modern Systems Analysis and Design

The Interface Concept

Chapter 3. Data Analysis and Diagramming

Chapter 1 Java Program Design and Development

UML Tutorial: Part 1 -- Class Diagrams.

Design by Contract beyond class modelling

Foundations of Information Management

7.1 The Information system

Unit Testing & JUnit

COMP 378 Database Systems Notes for Chapter 7 of Database System Concepts Database Design and the Entity-Relationship Model

Managing Variability in Software Architectures 1 Felix Bachmann*

CSE 1020 Introduction to Computer Science I A sample nal exam

Fundamentals of Java Programming

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

VB.NET - CLASSES & OBJECTS

XV. The Entity-Relationship Model

Business Definitions for Data Management Professionals

Chapter 4 OOPS WITH C++ Sahaj Computer Solutions

Using UML Part Two Behavioral Modeling Diagrams

Topic # 08. Structuring System Process Requirements. CIS Life Cycle and Requirements Structuring Stage

Engineering Process Software Qualities Software Architectural Design

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.

Object Oriented Databases (OODBs) Relational and OO data models. Advantages and Disadvantages of OO as compared with relational

BCS HIGHER EDUCATION QUALIFICATIONS Level 6 Professional Graduate Diploma in IT. March 2013 EXAMINERS REPORT. Software Engineering 2

Transcription:

UML Class Diagrams 11 November 2015 UML Class Diagrams The class diagram provides a static structure of all the classes that exist within the system. Classes are arranged in hierarchies sharing common structure and behaviour and are associated with other classes. Class diagrams are used in: Analysis To build a conceptual domain model with semantic associations between concepts Design Structural model of a design in terms of class interfaces Implementation Source code documentation, exposing the implementation 2 1

Classes and Objects Objects looks like modules in some ways Object = Identity + State + Behaviour Objects provide encapsulation of data. An object is described by a class. A class may define a number of objects with identical properties. 3 About a Class An class has a public interface defining the operations (methods) it will support A class has private data called attributes, which only its own operations can access A class can have private operations for its own use A class may know about other classes by means of associations 4 2

Classes A class is simply represented as a box with the name of the class inside The diagram may also show the attributes and operations Rectangle Rectangle Rectangle Rectangle height width height width getarea resize The complete signature of an operation is: height: int width: int getarea(): int resize(int,int) operationname(parametername: parametertype ): returntype 5 From UML Distilled 2 nd Ed. Martin Fowler (Covers UML 1.4) 6 3

From UML Distilled 3 rd Ed. Martin Fowler (Covers UML2.0) 7 Essentials of UML Class Diagrams 1of2 The main symbols shown on class diagrams are: Classes Represent the types of data themselves Associations Represent linkages between instances of classes Attributes Are simple data found in classes and their instances Operations Represent the functions performed by the classes and their instances Generalizations Group classes into inheritance hierarchies 8 4

9 Essentials of UML Class Diagrams 2of2 Constraints Extensions of the semantics of a UML element, allowing you to add new rules or modify existing ones. A constraint specifies conditions that a run-time configuration must satisfy to conform to the model. A constraint is rendered as a string enclosed by brackets and placed near the associated element. Navigation Given a plain, unadorned association between two classes, it is possible to navigate from objects of one kind to objects of the other kind. Unless otherwise specified, navigation across an association is bidirectional. However there are circumstances in which you will want to be able to limit navigation to just one direction. Specifying that an association is navigable is a statement that, given an object at one end, you can easily and directly get to objects at the other end, usually because the source object store some references to objects of the target. 10 5

Navigation: Example Bidirectional association navigation Unidirectional association 11 12 6

Identifying objects? A possible recipe We can identify objects in our problem context by looking for nouns and noun phrases Each of these can be underlined and becomes a candidate for an object in our solution Eliminate irrelevant objects Redundant, vague, event, outside scope, attribute, meta-language 13 The Bank Account Example You are asked to design a system to handle current and savings accounts for a bank. Accounts are assigned to one or more customers, who may make deposits or withdraw money. Each type of account earns interest on the current balance held in it. Current accounts may have negative balances (overdrafts) and then interest is deducted. Rates of interest are different for each type of account. On a savings account, there is a maximum amount that can be withdrawn in one transaction. Bank employees may check any account that is held at their branch. They are responsible for invoking the addition of interest and for issuing statements at the correct times. A money transfer is a short lived record of an amount which has been debited from one account and has to be credited to another. A customer may create such a transfer from their account to any other. Transfers within a branch happen immediately, while those between branches take three days. 14 7

The Bank Account Example You are asked to design a system to handle current and savings accounts for a bank. Accounts are assigned to one or more customers, who may make deposits or withdraw money. Each type of account earns interest on the current balance held in it. Current accounts may have negative balances (overdrafts) and then interest is deducted. Rates of interest are different for each type of account. On a savings account, there is a maximum amount that can be withdrawn in one transaction. Bank employees may check any account that is held at their branch. They are responsible for invoking the addition of interest and for issuing statements at the correct times. A money transfer is a short lived record of an amount which has been debited from one account and has to be credited to another. A customer may create such a transfer from their account to any other. Transfers within a branch happen immediately, while those between branches take three days. Question? Recognize the nouns! 15 Nouns in the bank account example You are asked to design a system to handle current and savings accounts for a bank. Accounts are assigned to one or more customers, who may make deposits or withdraw money. Each type of account earns interest on the current balance held in it. Current accounts may have negative balances (overdrafts) and then interest is deducted. Rates of interest are different for each type of account. On a savings account, there is a maximum amount that can be withdrawn in one transaction. Bank employees may check any account that is held at their branch. They are responsible for invoking the addition of interest and for issuing statements at the correct times. A money transfer is a short lived record of an amount which has been debited from one account and has to be credited to another. A customer may create such a transfer from their account to any other. Transfers within a branch happen immediately, while those between branches take three days. 16 8

Nouns eliminated Redundant - overdraft, account Vague - amount, money An event or an operation - transaction, deposit Outside scope of system - bank, days An attribute - interest, rate of interest, maximum amount, current balance, overdraft Meta-language - transaction, correct times, record 17 Nouns left current account, savings account, customer, branch, statement, transfer Remark: The Bank Account is derived from Pauline Wilcox The Unified Modelling Language in Msc in Systems Level Integration Systems Partitioning Module 18 9

Association Association is a relationship between two classes (objects). Whenever a class use another class, there exists a relationship between the two classes, this relationship is known as association. Association talks about relationship between objects in general. Example: Association Adornments: Name, Role The association has a name - the descriptive term, often a verb, for the association. Each association has two association ends; each end is attached to one of the classes in the association. An end can be explicitly named with a label. This label is called a role name (association ends are often called roles). Person employee works for employer Company Person employee has employment for employer Company 20 10

Association: Multiplicity Multiplicity defines the number of objects associated with an instance of the association. Default of 1 (1: 1) 0 or 1: 0..1 Zero or more (0..infinite): * 1 or more (1..infinite): 1..* n..m; range from n to m inclusive Car Car Car Car Car transports transports transports transports transports passenger 5 passenger * passenger 1..* passenger 2..5 passenger Person Person Person Person Person 21 Association classes Sometimes an attribute that concerns two associated classes cannot be placed in either of the classes Student * * CourseSection Registration grade Student Registration * * grade CourseSection 22 11

Attribute Analysis It is not always clear which attributes belongs to which classes by finding out the class attributes. An attribute is assigned to that class where it is certainly a feature. For example: a project leader has the attributes name, department and age. But what to do with the attributes project number, project duration, starting time, and budget? These attributes clarifies something about the relation between project leader and type of project. This often happens if a n:m relation refers to an association between two classes. In that case, we can define a new class, for instance project management. 23 24 12

Generalization A specialization / generalization relationship, in which objects of the specialized element (child) are substitutable for objects of the generalized element (parent). Superclass the generalization of another class, the child. Subclass the specialization of another class, the parent. Customer Corporate Personal Customer Customer 25 Generalization - characteristics Identify common features concerning behaviour and knowledge. Define these common features on a higher level in the inheritance hierarchy. The aim is at behaviour more than knowledge when combining classes. Generalization is a bottum-up process. A superclass includes all common properties of its subclasses. 26 13

Specialization - characteristics Define a new class which is a special appearance of an existing class. Specialization is a top-down process. A subclass can have attributes and operations that are specific for that sub-class. A subclass may redefine operations of its super-class. 27 28 14

Associations vs. Generalizations Associations describe the relationships that will exist between instances at run time when you show an instance diagram generated from a class diagram, there will be an instance of both classes joined by an association Generalizations describe relationships between classes in class diagrams they do not appear in instance diagrams at all an instance of any class should also be considered to be an instance of that class s super classes 29 Aggregation Aggregations are special associations that represent partwhole relationships the whole side is often called the assembly or the aggregate ( has-a relationship) Vehicle * VehiclePart Country * Region 30 15

Composition A composition is a strong kind of aggregation if the aggregate is destroyed, then the parts are destroyed as well Building * Room 31 Difference between Aggregation and Composition Association talks about relationship between two classes (objects) in general. Any type of relationship between two objects is called association. Aggregation is more restricted form of association. When a object has a ownership of another object, there exists aggregation between objects. However, this ownership does not mean that: without Parent object child object would not exist. Composition is again the more restricted form of aggregation. When a object has a ownership of another object and without Parent object, child object can not exist, there exists composition. 16

Association, Aggregation, Composition? What is OK? A or B or None A B 33 Association, Aggregation, Composition? What is OK? A or B or None A B 34 17

Association, Aggregation, Composition? What is OK? A or B or None A B 35 Association, Aggregation, Composition? What is OK? A or B or None A B 36 18

Aggregation and Composition: example A B Question: What is OK? 1. A 2. B 3. A & B 4. None 37 Object diagram An object diagram is shown as a class, and the name is underscored, although an object s name can be shown optionally preceding the class name as: objectname: classname. The object does not have to be named, in which case only the classname is shown underscored. 38 19

Class diagram Object diagram : example Author name: String age: Integer 0..* 1..* Computer name: String memory: String Derive from this class diagram an object diagram consisting of 1 author and 2 computers. 39 Class diagram Object diagram : example Author name: String age: Integer 0..* 1..* Computer name: String memory: String Brian: Author name = Brain Jones age = 35r Brian s PC: Computer name = Dell 486 memory = 256MB Brian slaptop: Computer name = Toshiba CT memory = 512MB 40 20

References Timothy Lethbridge & Robert Laganière (2005) Object-Oriented Software Engineering, 2 nd edition http://www.lloseng.com Martin Fowler (2000, 2004) Object-Oriented Software Engineering, 2 nd edition; 3 rd edition 41 21