UML class diagrams. Nigel Goddard. School of Informatics University of Edinburgh

Similar documents
Class diagrams and architectural design

A - 1. CS 494 Object-Oriented Analysis & Design. UML Class Models. Overview. Class Model Perspectives (cont d) Developing Class Models

Software Design Models, Tools & Processes. Lecture 3: Addendum Cecilia Mascolo

Agenda. More on the Unified Modeling Language. UML diagram types. Packages

Software component interactions and sequence diagrams

12 Tutorial on UML. TIMe TIMe Electronic Textbook

Object-Oriented Software Engineering Practical Software Development using UML and Java

Chapter 10 Object-Oriented Design Principles

Class diagrams. Modeling with UML Chapter 2, part 2. Class Diagrams: details. Class diagram for a simple watch

Limitations in Mapping from UML to Java Shakeel Sadiq Computer Science (2002/2003)

UML Tutorial. Unified Modeling Language UML Tutorial

Class Diagram. Classes consist of. Note that class diagrams contain only classes, not objects.

UML big picture. Perdita Stevens. School of Informatics University of Edinburgh

Object-Oriented Software Engineering Practical Software Development using UML and Java. Chapter 5: Modelling with Classes

University of Calgary Department of Electrical and Computer Engineering. SENG : Object Oriented Analysis and Design Behrouz Homayoun Far

Class Diagram. Classes consist of. Note that class diagrams contain only classes, not objects.

2. Introduction to UML & Discussion of Related S.E.

What is a Class Diagram? A diagram that shows a set of classes, interfaces, and collaborations and their relationships

What is a Class Diagram? Class Diagram. Why do we need Class Diagram? Class - Notation. Class - Semantic 04/11/51

COSC 3351 Software Design. An Introduction to UML (I)

Chapter 5: Procedural abstraction. Function procedures. Function procedures. Proper procedures and function procedures

Principles of Software Construction: Objects, Design and Concurrency. Just enough UML. toad

Introduction to Software Engineering. 5. Modeling Objects and Classes

S T R U C T U R A L M O D E L I N G ( M O D E L I N G A S Y S T E M ' S L O G I C A L S T R U C T U R E U S I N G C L A S S E S A N D C L A S S D I A

administrivia today UML start design patterns Tuesday, September 28, 2010

Design Engineering. Dr. Marouane Kessentini Department of Computer Science

Object- Oriented Analysis, Design and Programming

Lecture 13: Analysis Modeling

Object-Oriented Software Engineering Re-exam, 2012 (Also Object-Oriented Analysis, Design and Programming, Re-exam, 2012)

UML Fundamental. OutLine. NetFusion Tech. Co., Ltd. Jack Lee. Use-case diagram Class diagram Sequence diagram

SE 1: Software Requirements Specification and Analysis

Modelling with Classes. CITS1220 Software Engineering

Introduction to Unified Modelling Language (UML)

ACS-3913 Ron McFadyen 1. UML Notation for Class diagrams Object diagrams

25. Interfaces. Java. Summer 2008 Instructor: Dr. Masoud Yaghini

A Conceptual Model of the UML

Software Specification 2IX20

Inheritance and Interfaces

The Unified Modeling Language. Asst.Prof.Dr. Supakit Nootyaskool IT-KMITL

ITI Introduction to Computing II

Developing Shlaer-Mellor Models Using UML

UML REFERENCE SHEETS. 2013, 2014 Michael Marking; all rights reserved, including moral rights. Web site:

Contents. I. Classes, Superclasses, and Subclasses. Topic 04 - Inheritance

CSE 403: Software Engineering, Spring courses.cs.washington.edu/courses/cse403/15sp/ UML Class Diagrams. Emina Torlak

Automation of Semantic Web based Digital Library using Unified Modeling Language Minal Bhise 1 1

Chapter 2: The Object-Oriented Design Process

Structural specification

Object Oriented Software Development CIS Today: Object Oriented Analysis

ITI Introduction to Computing II

Unified Modeling Language (UML) Class Diagram

Inheritance. Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L

CS111: PROGRAMMING LANGUAGE II. Lecture 1: Introduction to classes

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub

A4 Explain how the Visitor design pattern works (4 marks)

Introduction to Unified Modelling Language (UML)

26. Interfaces. Java. Fall 2009 Instructor: Dr. Masoud Yaghini

OOADP/OOSE Re- exam. 23 August Mapping marks onto grades. Answers

MSO Analysis & UML. Hans Philippi (based on the course slides of Wouter Swierstra) August 24, Analysis & UML 1 / 56

System Analysis & design

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

NOTES ON OBJECT-ORIENTED MODELING AND DESIGN

CS112 Lecture: Defining Classes. 1. To describe the process of defining an instantiable class

CMPT 354 Database Systems I

Chapter 6 Introduction to Defining Classes

Software Engineering I (02161)

OBJECT ORIENTED DESIGN with the Unified Process. Use Case Realization

UML Sequence Diagrams for Process Views

The learning objectives of this chapter are the followings. At the end of this chapter, you shall

Model Driven Development Unified Modeling Language (UML)

UML Class Diagrams Revisited

CSC9T4: Object Modelling, principles of OO design and implementation

Model-Based Requirements Engineering. Tutorial by Kristian Sandahl

Introduction to UML What is UML? Motivations for UML Types of UML diagrams UML syntax Descriptions of the various diagram types Rational Rose (IBM.. M

Anatomy of a Class Encapsulation Anatomy of a Method

Introduction to UML. Danang Wahyu utomo

Problem with Scanning an Infix Expression

2 UML for OOAD. 2.1 What is UML? 2.2 Classes in UML 2.3 Relations in UML 2.4 Static and Dynamic Design with UML. UML for OOAD Stefan Kluth 1

Object Oriented Methods with UML

Conceptual Design with ER Model

Midterm Exam (REGULAR SECTION)

Lesson 11. W.C.Udwela Department of Mathematics & Computer Science

Computer Science 1 Bh

UML Profiles Radovan Cervenka

SOFTWARE DESIGN COSC 4353 / Dr. Raj Singh

Guided Tour: Intelligent Conceptual Modelling in EER and UML-like class diagrams with icom compared to ORM2

(C) 2010 Pearson Education, Inc. All rights reserved. Dr. Marenglen Biba

An Introduction to Subtyping

Computer Science II (20073) Week 1: Review and Inheritance

Relationships. Association Aggregation/Composition Multiplicity Dependencies

CPS122 Lecture: Detailed Design and Implementation

Declarations and Access Control SCJP tips

Objects and Classes. 1 Creating Classes and Objects. CSCI-UA 101 Objects and Classes

Intro to Haskell Notes: Part 5

Chapter No. 2 Class modeling CO:-Sketch Class,object models using fundamental relationships Contents 2.1 Object and Class Concepts (12M) Objects,

CSE 403 Lecture 8. UML Class Diagrams. Thanks to Marty Stepp, Michael Ernst, and other past instructors of CSE 403

CS304 Object Oriented Programming Final Term

OBJECT ORIENTED DESIGN with the Unified Process. Use Case Realization

Object-Oriented Modeling. Sequence Diagram. Slides accompanying Version 1.0

Defining Classes and Methods

Encapsulation. Administrative Stuff. September 12, Writing Classes. Quick review of last lecture. Classes. Classes and Objects

Transcription:

UML class diagrams Nigel Goddard School of Informatics University of Edinburgh

A class Book A class as design entity is an example of a model element: the rectangle and text form an example of a corresponding presentation element.

A class Book A class as design entity is an example of a model element: the rectangle and text form an example of a corresponding presentation element. UML explicitly separates concerns of actual symbols used vs meaning.

A class Book A class as design entity is an example of a model element: the rectangle and text form an example of a corresponding presentation element. UML explicitly separates concerns of actual symbols used vs meaning. Many other things can be model elements: use cases, actors, associations, generalisation, packages, methods,...

An object jo : Customer This pattern generalises: always show an instance of a classifier using the same symbol as for the classifier, labelled instancename : classifiername.

Classifiers and instances An aspect of the UML metamodel that it s helpful to understand up front. An instance is to a classifier as an object is to a class: instance and classifier are more general terms. In the metamodel, Class inherits from Classifier, Object inherits from Instance. UML defines many different classifiers. E.g., UseCase and Actor are classifiers.

Showing attributes and operations Book title : String copiesonshelf() : Integer borrow(c:copy) Syntax for signature of operations (argument and return types) adaptable for different programming languages. May be omitted

Compartments We saw the standard: a compartment for attributes a compartment for operations, below it

Compartments We saw the standard: a compartment for attributes a compartment for operations, below it They can be suppressed in diagrams. They are omitted if empty. You can have extra compartments labelled for other purposes, e.g., responsibilities of the class...

Visibility Book + title : String - copiesonshelf() : Integer # borrow(c:copy)

Visibility Book + title : String - copiesonshelf() : Integer # borrow(c:copy) Can show whether an attribute or operation is public (visible from everywhere) with +

Visibility Book + title : String - copiesonshelf() : Integer # borrow(c:copy) Can show whether an attribute or operation is public (visible from everywhere) with + private (visible only from inside objects of this class) with

Visibility Book + title : String - copiesonshelf() : Integer # borrow(c:copy) Can show whether an attribute or operation is public (visible from everywhere) with + private (visible only from inside objects of this class) with (Or protected (#), package ( ) or other language dependent visibility.)

Association between classes Copy is a copy of Book This generalises: association between classifiers is always shown using a plain line. (Recall the associations between actors and use cases!)

Association between classes Copy is a copy of Book This generalises: association between classifiers is always shown using a plain line. (Recall the associations between actors and use cases!) An instance of an association connects objects (e.g. Copy 3 of War and Peace with War and Peace).

Association between classes Copy is a copy of Book This generalises: association between classifiers is always shown using a plain line. (Recall the associations between actors and use cases!) An instance of an association connects objects (e.g. Copy 3 of War and Peace with War and Peace). An object diagram contains objects and links: occasionally useful.

Rolenames on associations Director of Studies DoS directee Student Can show the role that one object plays to the other.

Rolenames on associations Director of Studies DoS directee Student Can show the role that one object plays to the other. Useful when documenting the class: e.g. a class invariant for DirectorOfStudies could refer to the associated Student objects as self.directee (a set, if there can be more than one).

Rolenames on associations Director of Studies DoS directee Student Can show the role that one object plays to the other. Useful when documenting the class: e.g. a class invariant for DirectorOfStudies could refer to the associated Student objects as self.directee (a set, if there can be more than one). Can use visibility notation + etc on role names too.

Class invariants A class invariant is a statement which is supposed to be true of every object of the class, all the time - a sanity check. Very useful to make these explicit. Can be included as comments on class diagrams, and in code.

Class invariants A class invariant is a statement which is supposed to be true of every object of the class, all the time - a sanity check. Very useful to make these explicit. Can be included as comments on class diagrams, and in code. May be formal, e.g. x + y = z, or informal, e.g. the attribute docstring describes the action of the button in concise English. If formal, it can be useful to have class invariants automatically checked.

Multiplicity of association Book 1 is a copy of 1..* LibraryMember borrows/returns 1 0..* Copy 0..* 1 borrows/returns MemberOfStaff borrows/returns 1 0..* Journal Commas for alternatives, two dots for ranges, * for unknown number. E.g. each Copy is a copy of exactly one Book; there must be at least one Copy of every Book.

Navigability Adding an arrow at the end of an association shows that some object of the class at one end can access some object of the class at the other end, e.g. to send a message. Student is taking Module Crucial to understanding the coupling of the system. NB direction of navigability has nothing to do with direction in which you read the association name.

Generalisation LibraryMember MemberOfStaff This generalises: generalisation between classifiers is always shown using this arrow.

Generalisation LibraryMember MemberOfStaff This generalises: generalisation between classifiers is always shown using this arrow. Usually, but not necessarily, corresponds to implementation with inheritance.

Abstract operations and classes An operation of a class is abstract if the class provides no implementation for it: thus, it is only useful if a subclass provides the implementation. A class which cannot be instantiated directly for example, because it has at least one abstract operation is also called abstract. Java...

Abstract operations and classes An operation of a class is abstract if the class provides no implementation for it: thus, it is only useful if a subclass provides the implementation. A class which cannot be instantiated directly for example, because it has at least one abstract operation is also called abstract. Java... Can show abstract operation or class using italics for the name, and/or using the property {abstract}.

Interfaces In UML an interface is just a collection of operations, that can be realised by a class. <<interface>> Stringifiable stringify() : String Module stringify() : String...... Stringifiable <<use>> Printer

Simpler diagram: WRITE ONCE <<interface>> Stringifiable stringify() : String Module stringify() : String...... prints Stringifiable Printer Many things other than classes can realise interfaces: can use the lollipop symbol on e.g. components, actors.

Clicker question In a class diagram, a class may have compartments for: 1. attributes 2. operations 3. responsibilities 4. all of the above, but nothing else 5. all of the above, and other items

Identifying objects and classes Simplest and best: look for noun phrases in the system description! Then abandon things which are: redundant outside scope vague attributes operations and events implementation classes. (May need to add some back later, especially implementation classes: point is to avoid incorporating premature design decisions into your conceptual level model.) Similarly, can use verb phrases to identify operations and/or associations

Reading Suggested: (class diagrams) Stevens ch 5.