The UML Class Diagram



Similar documents
UML Class Diagrams. Lesson Objectives

Software Project Management and UML

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

11 November

A terminology model approach for defining and managing statistical metadata

XV. The Entity-Relationship Model

III. Class and Object Diagrams

Database Management Systems

Lecture 12: Entity Relationship Modelling

IV. The (Extended) Entity-Relationship Model

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

Enhanced-ER Data Model

Database Design Methodology

How To Design Software

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

History OOP languages Year Language 1967 Simula Smalltalk

CSC 742 Database Management Systems

Object Oriented Software Models

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

Chapter 8 The Enhanced Entity- Relationship (EER) Model

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

Umbrello UML Modeller Handbook

Data Analysis 1. SET08104 Database Systems. Napier University

Java (12 Weeks) Introduction to Java Programming Language

Graphical Systems Modeling with UML / SysML Class diagrams

Java Interview Questions and Answers

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

Object Oriented Design

AP Computer Science Java Subset

Tutorial - Building a Use Case Diagram

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

Best of Both Worlds - A Mapping from EXPRESS-G to UML

Domain Modeling. Domain Modeling

Schema Classes. Polyhedra Ltd

Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007

Business Definitions for Data Management Professionals

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

Using UML Part One Structural Modeling Diagrams

How to Make a Domain Model. Tutorial

Modern Systems Analysis and Design

Teaching Object-Oriented Concepts with Eclipse

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

Visual Basic Programming. An Introduction

Java 6 'th. Concepts INTERNATIONAL STUDENT VERSION. edition

Entity - Relationship Modelling

Object-Oriented Data Modeling

Java Application Developer Certificate Program Competencies

Transmodel in UML. SITP 2 Système d'information Transport Public

The Interface Concept

Design by Contract beyond class modelling

UML FOR OBJECTIVE-C. Excel Software

Part I. Multiple Choice Questions (2 points each):

Menouer Boubekeur, Gregory Provan

three Entity-Relationship Modeling chapter OVERVIEW CHAPTER

UNIVERSITY OF SURREY

Flowcharting, pseudocoding, and process design

Transaction-Typed Points TTPoints

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

A technical discussion on modeling with UML 06/11/03 Entity Relationship Modeling with UML

Introduction to formal semantics -

III. Class and Object Diagrams

Entity-Relationship Model

An Approach for Generating Concrete Test Cases Utilizing Formal Specifications of Web Applications

Artificial Intelligence

Introduction to Java Applications Pearson Education, Inc. All rights reserved.

CS104: Data Structures and Object-Oriented Design (Fall 2013) October 24, 2013: Priority Queues Scribes: CS 104 Teaching Team

An Introduction To UML Class Diagrams Classes

Translating to Java. Translation. Input. Many Level Translations. read, get, input, ask, request. Requirements Design Algorithm Java Machine Language

Object-Oriented Programming: Polymorphism

Semantics of UML class diagrams

Data Modeling Basics

CS 111 Classes I 1. Software Organization View to this point:

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

DATABASE DESIGN. - Developing database and information systems is performed using a development lifecycle, which consists of a series of steps.

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

Automatic Test Data Generation for TTCN-3 using CTE

A Common Metamodel for Code Generation

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

Software Development: An Introduction

Chapter 1 Java Program Design and Development

Object Oriented Software Design

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program

1. Graphing Linear Inequalities

Detecting Defects in Object-Oriented Designs: Using Reading Techniques to Increase Software Quality

Outline. Data Modeling. Conceptual Design. ER Model Basics: Entities. ER Model Basics: Relationships. Ternary Relationships. Yanlei Diao UMass Amherst

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program

Microsoft Dynamics GP

Structural Modeling and Analysis

The Java Series. Java Essentials I What is Java? Basic Language Constructs. Java Essentials I. What is Java?. Basic Language Constructs Slide 1

Software Engineering. System Modeling

UML Modeling Guidelines

LAB 3: Introduction to Domain Modeling and Class Diagram

Doing database design with MySQL

Data Modeling. Database Systems: The Complete Book Ch ,

Java the UML Way: Integrating Object-Oriented Design and Programming

A brief overview of developing a conceptual data model as the first step in creating a relational database.

Transcription:

The UML Class Diagram Is a static diagram (describes system structure) Combines a number of model elements: Classes Attributes Operations (methods) Associations Aggregations Compositions Generalisations

A UML Class Name Attributes Operations Properties of class diagrams: - Static model; - Models structure and behaviour; - Used as a basis for other diagrams; - Easily converted to an object diagram.

Determining Classes (1/2) Is there data that requires storage, transformation or analysis? Are there external systems interacting with the one in question? Are any class libraries or components being use (from manufacturers, other colleagues or past projects)? Does the system handle any devices? Does the system model organisational structures? Analyse all actor roles.

Determining Classes (2/2) Textual Analysis (based on Dennis, 2002) A common or improper noun implies a class A proper noun or direct reference implies an object (instance of a class) A collective noun implies a class made up of groups of objects from another class An adjective implies an attribute A doing verb implies an operation A being verb implies a classification relationship between an object and its class A having verb implies an aggregation or association relationship A transitive verb implies an operation An intransitive verb implies an exception A predicate or descriptive verb phrase implies an operation An adverb implies an attribute of a relationship or an operation

UML Class Attributes (1/2) Very system dependent Describe characteristics of objects belonging to that class Can be informative - or confusing Has a definite type Primitive (Boolean, integer, real, enumerated, etc.) language specific other classes any user defined type Has different visibility, including: public (viewed and used from other classes) private (cannot be accessed from other classes)

UML Class Attributes (2/2) Can be given a default value Can be given class-scope Can list possible values of enumeration Directly implementable into most modern programming languages with object-oriented support (e.g. Java) Attribute syntax: Visibility name:type=init_value{property_string}

UML Class Attribute Examples UNIXaccount + username : string + groupname : string + filesystem_size : integer + creation_date : date - password : string UNIXaccount + username : string + groupname : string = staff" + filesystem_size : integer + creation_date : date - password : string Invoice + amount : real + date : date = current date + customer : string + specification : string - administrator : string = "unspecified" - number_of_invoices : integer Invoice + amount : real + date : date = current date + customer : string + specification : string - administrator : string = "unspecified" - number_of_invoices : integer + status : status = unpaid { unpaid, paid }

UML Class-to-Java Example Public class UNIXaccount { public string username; public string groupname = "csai"; public int filesystem_size; public date creation_date; private string password; static private integer no_of_accounts = 0 public UNIXaccount() { //Other initialisation no_of_accounts++; } //Methods go here }; UNIXaccount + username : string + groupname : string = staff" + filesystem_size : integer + creation_date : date - password : string - no_of_accounts : integer = 0

Operations (Methods) Public class Figure { private int x = 0; private int y = 0; public void draw() { //Java code for drawing figure } }; Figure fig1 = new Figure(); Figure fig2 = new Figure(); fig1.draw(); fig2.draw(); - x : integer = 0 - y : integer = 0 + draw() Figure

Constraints on Operations PoliceStation alert (Alarm) 1 station * BurglarAlarm istripped: Boolean = false report () { if istripped then station.alert(self)}

Association Examples Person * Driver Drives * Company car Car Person * Adult Driver 1 1 Employee Driver Drives * Company car Car Person Husband Married to Wife Person Heater Turns on Mum Domestic appliance Cleans Toaster Tunes Dad Family member Radio Child

Qualified and "Or" Associations Person Plates * Car User PID * Process IP-addr * Host Item of clothing 1 0..* Male person 1 {or} 0..* Female person

Ordered and Ternary Associations Library 1..* * {ordered by date} Books 1..* * {ordered by surname} Member No qualified or aggregation associations allowed in ternary. 0..* Credit card Bank card 1..* Client Person 1..* Shop Establishment

Another Ternary Association Example Year season Team team goalkeeper Player Record goals for goals against wins losses ties

Association Classes Host * Computer Adapter Network adapter Queue Notary 1 Network 1 Print spooler 1..* Printer Purchaser Real-estate Client Contract

Association by Aggregation

Alternative Notation for Composition Association Car Wheels Body Engine * * * Wiring * Note that association multiplicity is shown within the classes

Roles in Aggregation My family Zoo Ernest Fiona Family member My family Ernest: Family member Fiona: Family member 1..* Cage 1..* 0..* 0..* Falcon 0..* Mammal Bird Equipment Zoo Monkey[0..*]: Mammal Giraffe[0..*]: Mammal Human[1..*]: Mammal Falcon[0..*]: Bird Cage[1..*]: Equipment

Abstract Classes

Abstract Classes and Generalisation Example Aircraft {abstract} Make Seats Engine type Start() {abstract} land() {abstract} Jet plane Helicopter Make Seats Engine type Start() land() Start jet engines Make Seats Engine type Start() land() Start blades Lower flaps & landing gear Decrease prop speed

Aggregation and Generalisation Figure {abstract} Consists of * Position: Pos Draw() {abstract} * Consists of Electronic Canvas Group Polygon Line Circle Consists of * Draw() Draw() Draw() Draw()

Implementing it (e.g. in Java) abstract public class Figure { abstract public void Draw(); Pos position; } public class Group extends Figure { private FigureVector consist_of; public void Draw() { for (int i = 0; i < consist_of.size(), i++) public class Line extends Figure { public void Draw() { /* code to draw line */ } } public class circle extends Figure { public void Draw() { /* code to draw circle */ { consist_of[i].draw(); } } } public class Polygon extends Figure { public void Draw() } } { /* something similar to group only using lines instead */ } }

Constrained Generalisations Overlapping A type of inheritance whereby sharing of common sub-classes by other sub-classes is allowed. Disjoint (the default) The opposite of overlapping. Complete A type of inheritance whereby the existing subclasses are said to fully define a given super-class. No further sub-classing may be defined. Incomplete (the default) Further sub-classes can be added later on to more concretely specify a given super-class.

Overlapping Generalisation Electronic device {overlapping} Radio receiver Amplifier Monitor unit TV set

Complete Generalisation University faculty component {complete} University department University institute Person {complete} Man Woman

Expressing Rules in UML Rules are expressed using constraints and derivations Constraints were mentioned earlier (e.g. orassociations, ordered associations, inheritance constraints, etc.) Derivations are rules governing how entities can be derived (e.g. age = current date - DOB)

Example of Derived Associations Uses uses Fixed-wing passenger craft Airport Flight Aircraft Is on Passenger Name Surname Age Nationality Destination Ticket price /1 class passenger /1 class passenger Passenger /1 class passenger Turbo-prop aircraft Jet-turbine aircraft {1 class passenger = = (Ticket price > 400)} N.B. Relation cardinality is omitted for example clarity

Another Example of a Derived Association /supermarket Wholesaler Supplies Shop Processes Order Shop Name Address Owner Category Date of registration Area /Supermarket /bulk-buying customer Places Customer {Supermarket = = (Area > 200 && Category = "dept")} N.B. Relation cardinality is omitted for example clarity

Example of a Constraint Association Database Organisation {subset} Member of Maintains Project manager of Entry in Employee N.B. Relation cardinality is omitted for example clarity

Association Class

Class Dependencies ClassA «friend» ClassB ClassD «instantiate» «friend» operationz() «call» ClassC «refine» ClassC combines two logical classes ClassD ClassE

Concrete Dependency Example Controller «access» «access» «access» Diagram Elements «access» «access» Domain Elements Graphics Core

Class Diagram Example Element C Carbon C <<covalent>> H Hydrogen <<covalent>> C

Instantiation of Class Diagram (in previous slide) :Hydrogen :Hydrogen :Hydrogen :Carbon :Carbon :Hydrogen :Hydrogen :Hydrogen

Another Class Diagram Example CreditCard {abstract} MyCreditCard <<interface>> EntityBean order * OrderBean {abstract} +getorderstatus +setorderstatus +getlineitems +setlineitems +getcreditapproved +setcreditapproved... MyOrder 1 order buyer 1 * item Customer LineItem {abstract} * item MyLineItem * 1 commodity Product

Try This Yourselves Create a class diagram to represent a arbitrary interconnection of computers Create a class diagram to represent a hierarchical directory system in any OS