Software Specification 2IX20

Similar documents
Structural specification

Course "UML and Design Patterns" of module "Software Engineering and Design", version February 2011 (X)

UML Is Not a Methodology

Class Diagrams in Analysis

Introduction to Software Engineering. 5. Modeling Objects and Classes

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

Introduction to Unified Modelling Language (UML)

Engineering Design w/embedded Systems

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

Computer Science for Engineers

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

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

Software Modelling. UML Class Diagram Notation. Unified Modeling Language (UML) UML Modelling. CS 247: Software Engineering Principles

SE 1: Software Requirements Specification and Analysis

CS 247: Software Engineering Principles. UML Modelling

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

Introduction to Software Engineering. 5. Modeling Objects and Classes

Object-Oriented and Classical Software Engineering

22/09/2012 INFO2110. Copyright Warning. Revision of class diagram. Overview. Purpose of class diagram. Generalization Relationship

Motivation State Machines

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

2D1358 Object Oriented Program Construction in C++ Exercises & Labs. Course Registration / Accounts. Course Literature

Chapter 5: Structural Modeling

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

Introduction to UML Diagrams

Object-Oriented Analysis and Design. Pre-UML Situation. The Unified Modeling Language. Unification Efforts

Software Service Engineering

Class diagrams and architectural design

Credit where Credit is Due. Lecture 4: Fundamentals of Object Technology. Goals for this Lecture. Real-World Objects

Unified Modeling Language (UML) Class Diagram

Object-Oriented Design

Lecture 33 April 4, Unied Modelling Language. ECE155: Engineering Design with Embedded Systems Winter Patrick Lam version 1

CS/IT Secure Software Construction

Chapter 14 Abstract Classes and Interfaces

Notation Part 1. Object Orientated Analysis and Design. Benjamin Kenwright

Abstract Class. Lecture 21. Based on Slides of Dr. Norazah Yusof

Unified Modeling Language (UML)

Today s Topic. Lecture 5. What is UML? Why Use UML. UML Diagrams. Introduction to UML. What is UML Why use UML? UML Diagrams

UML: Unified Modeling Language

Composite Structures

Software Engineering I (02161)

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

OO Techniques & UML Class Diagrams

Software Engineering 2 A practical course in software engineering. Ekkart Kindler

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

Week 9 Implementation

12 Tutorial on UML. TIMe TIMe Electronic Textbook

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

Object Orientated Analysis and Design. Benjamin Kenwright

SOFTWARE DESIGN COSC 4353 / Dr. Raj Singh

From Analysis to Design. LTOOD/OOAD Verified Software Systems

2.0.3 attributes: A named property of a class that describes the range of values that the class or its instances (i.e., objects) may hold.

Chapter 13 Abstract Classes and Interfaces

Software Engineering I (02161)

2.0.3 attributes: A named property of a class that describes the range of values that the class or its instances (i.e., objects) may hold.

to schedule pressure

CSE 341, Autumn 2015, Ruby Introduction Summary

Introduction Programming Using Python Lecture 8. Dr. Zhang COSC 1437 Fall 2017 Nov 30, 2017

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

CSC9T4: Object Modelling, principles of OO design and implementation

Architecture and the UML

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

2.1 Introduction UML Preliminaries Class diagrams Modelling delegation... 4

Software Engineering I (02161)

Object Modeling. Entity-Relationship (ER) diagrams (1976) Object Modelling Technique (OMT) diagrams (1991)

Design Patterns: State, Bridge, Visitor

02291: System Integration

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

Software Specification 2IX20

Chapter 1: Principles of Programming and Software Engineering

MTAT Software Engineering. Written Exam 17 January Start: 9:15 End: 11:45

Welcome to Design Patterns! For syllabus, course specifics, assignments, etc., please see Canvas

Object Oriented Software Development CIS Today: Object Oriented Analysis

Chapter 8: Enhanced ER Model

The Unified Modeling Language (UML)

Introduction to OO Concepts

Database Applications (15-415)

CS 200 More Classes Jim Williams, PhD

MSc programme (induction week) Department of Informatics INTRODUCTION TO UML

Unified Modeling Language

Curriculum Map Grade(s): Subject: AP Computer Science

Design and UML Class Diagrams

Lecture 5: Inheritance

Object-Oriented Programming Paradigm

Advanced UML Class Models

Introduction to Unified Modelling Language (UML)

Tutorial notes on. Object relational structural patterns

Relational Database design. Slides By: Shree Jaswal

Software Specification 2IX20

Fundamentals of Databases

UML Modeling I. Instructor: Yongjie Zheng September 3, CS 490MT/5555 Software Methods and Tools

Object-Oriented Concepts and Principles (Adapted from Dr. Osman Balci)

UML Tutorial. Unified Modeling Language UML Tutorial

Ch t 8 Chapter 8. System Models

1. Which of the following is the correct expression of character 4? a. 4 b. "4" c. '\0004' d. '4'

UNIT 5 - UML STATE DIAGRAMS AND MODELING

Object-Oriented Design

High Level Database Models

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

Fuente. conceptual data modelling model

Transcription:

Software Specification 2IX20 Julien Schmaltz (slides from A. Serebrenik and M. Mousavi) Lecture 04: Structural specification / Class diagrams

UML diagram types Classes: Chapter 11.4 of the UML standard. 2

This week sources Slides of Mohammad Ch. 3,5 Mousavi 3

What is structure? Structure: the aggregate of elements of an entity in their relationships to each other. Merriam-Webster Structural modelling: discover the key data contained in the problem domain and to build a structural model of the objects Structural Modeling Problem Domain Solution Domain 4

So what is a structural diagram? A diagram that identifies modules, activities, or other entities in a system or computer program and shows how larger or more general entities break down into smaller, more specific entities. IEEE Standard Glossary of Software Engineering Terminology 610.12 1990 5

UML structure diagrams Class diagram Object diagram Packages diagram Component diagram Deployment diagram Composite structure diagram 6

Class diagrams» most common and most useful» describe the types of objects in the System and the various kinds of static relationships that exist among them» show the properties and operations of a Class and the constraints that apply to the way objects are connected [Martin Fowler, UML Distilled, 2003] 7

Properties, operations and constraints» show the properties and operations of a Class and the constraints that apply to the way objects are connected» Do you remember? properties (attributes and associations): units of data (responsibilities for knowing) operations: units of functionality (responsibilities for doing) constraints: conditions on attributes, pre- and postconditions of operations 8

Attributes and associations» Two different ways properties can be presented» Attribute property as a line of text within the class box.» Association property as a solid line between two classes, directed from the source class to the target class. Name is written on the line close to the target class. Order Order name: String name String 9

Navigability Car Car Car owner Person owner Person Person owns We can query Car about its owner but not Person about her cars. We can query Car about its owner, and Person about her cars. Moreover, x in cars(owner(x)), y in owner(cars(y)) No navigability information. 10

Closer look at the attributes Order +number: String [1] +placedon: Date [1] +deliveredon: Date [0..1] +totalamount: Money [1] +recipient: Name [1] +lineitems: OrderLine [1..*] {ordered} 11

How would we write this in UML? Order +number: String [1] +placedon: Date [1] +deliveredon: Date [0..1] +totalamount: Money [1] +recipient: Name [1] +lineitems: OrderLine [1..*] {ordered} Multiplicity how many objects may fill the attribute: m..n at least m at most n * denotes 12

How would we write this in UML? Order +number: String [1] +placedon: Date [1] +deliveredon: Date [0..1] +totalamount: Money [1] +recipient: Name [1] +lineitems: OrderLine [1..*] {ordered} Multiplicity how many objects may fill the attribute: m..n at least m at most n * denotes Additional Any kind of extra information needed about the attribute 13

How would we write this in UML? Order +number: String [1] +placedon: Date [1] +deliveredon: Date [0..1] +totalamount: Money [1] +recipient: Name [1] +lineitems: OrderLine [1..*] {ordered} Multiplicity how many objects may fill the attribute: m..n at least m at most n * denotes Visibility Which other classes can access this attribute? + (public) every other class - (private) no other class # (protected) only classes that inherit from Order Additional Any kind of extra information needed about the attribute 14

Order +number: String [1] +placedon: Date [1] +deliveredon: Date [0..1] +totalamount: Money [1] +recipient: Name [1] +lineitems: OrderLine [1..*] {ordered} +dispatch() +close() Attributes or associations? Differences? Advantages? Disadvantages? Combinations? Money 1 +totalamount OrderLine +recipient Name 1..* +lineitems {ordered} 1 * Order 1 * +dispatch() * +close() 1 * 1 String +number 1 +placedon Date 0..1 +deliveredon 15

Attribute or association?» Attribute Value is important, not identity: Date, Number, String Little behaviour and functionality» Association (i.e., a separate class) Identity is important: Customer, Order, Student, Book Complex behaviour or functionality 16

Attribute or association?» Attribute Value is important, not identity: Date, Number, String Little behaviour and functionality» Association (i.e., a separate class) Identity is important: Customer, Order, Student, Book Complex behaviour or functionality Order OrderLine 1..* +lineitems {ordered} 1 +number: String [1] +placedon: Date [1] +deliveredon: Date [0..1] +totalamount: Money [1] +recipient: Name [1] +dispatch() +close() 17

Attribute or association?» Attribute Value is important, not identity: Date, Number, String Little behaviour and functionality» Association (i.e., a separate class) Identity is important: Customer, Order, Student, Book Complex behaviour or functionality Order Do you agree? OrderLine 1..* +lineitems {ordered} 1 +number: String [1] +placedon: Date [1] +deliveredon: Date [0..1] +totalamount: Money [1] +recipient: Name [1] +dispatch() +close() 18

Special kind of association» Order lines do not really have identity» Two orders cannot share an order line» When an order is deleted, order lines do not survive http://blog.procurify.com/wp-content/uploads/2013/06/purchase-order.gif 19

Special kind of association» Order lines do not really have identity» Two orders cannot share an order line» When an order is deleted, order lines do not survive Composition http://blog.procurify.com/wp-content/uploads/2013/06/purchase-order.gif OrderLine 1..* +lineitems {ordered} 1 Order +number: String [1] +placedon: Date [1] +deliveredon: Date [0..1] +totalamount: Money [1] +recipient: Name [1] +dispatch() +close() 20

Does this make sense? Wheel 4 1 Car 21

Does this make sense? Wheel 4 1 Car No, we can have spare parts! 22

Does this make sense? Person 1..* 1 Committee 23

Does this make sense? Person 1..* 1 Committee No, persons might be members of multiple committees! 24

Weaker form: aggregation Wheel 4 1 Car Person 1..* 1 Committee» Aggregation: part of relation Parts can exist without the whole Parts can be shared by multiple wholes Whole can exist without its parts 25

Recipient we need more than a name» Customer name billing address private or corporate Customer #number: String [1] #name: Name [1] #address: String [0..1]» Generalisation The same notation as in use cases Corporate Customer +contractnumber: String [1] +contactname: Name [1] +creditrating: String [1] Private Customer +creditcardnumber: String [1] 26

Abstract class» We said private or corporate but the intention was private, corporate and nothing else! Customer #number: String [1] #name: Name [1] #address: String [0..1]» Abstract class cannot be directly instantiated. Instead, one instantiates an instance of a subclass. Corporate Customer +contractnumber: String [1] +contactname: Name [1] +creditrating: String [1] Private Customer +creditcardnumber: String [1] 27

Abstract class: Another example» GeometricObject is an abstract class» getarea() and getperimeter() are abstract methods Not implemented in GeometricObject but in its subclasses Why? / http://www.oxfordmathcenter.com/drupal7/node/35 SET / W&I 28

Abstract class: Another example» GeometricObject is an abstract class» getarea() and getperimeter() are abstract methods Not implemented in GeometricObject but in its subclasses Why? Because: Perimeters and Area depend on the shape. One cannot implement these methods without knowing what shape does the GeometricObject represent. / http://www.oxfordmathcenter.com/drupal7/node/35 SET / W&I 29

For classes A, B, C, D which class diagram(s) is/are illegal? A B A B» A) C) C D C D» B) A B D) A B C D C D 30

For classes A, B, C, D which class diagram(s) is/are illegal? A B A B» A) C) C D C D» B) A B D) A B C D C D illegal (cycle) illegal (cycle) 31

Back to Orders: another kind of relation» Dependency: the source uses the target in order to realise its functionality (but does not include an instance of it) High number of dependencies clutters the diagram. Less frequently shown than association, generalisation, composition and aggregation UML distinguishes more than 10 kinds of dependencies Stereotypes are frequently omitted Usually, target appears a parameter in source s operations. OrderLine 1..* +lineitems {ordered} 1 Order +updatepricefor(product) Product PAGE 45 32

Examples of dependencies» <<create>> Order creates entries in the log book» <<use>> Order uses information about products» <<call>> Order calls a System operation to obtain the current time» 33

Putting it all together Order +number: String [1] +placedon: Date [1] +deliveredon: Date [0..1] +approved: Boolean [1] +totalamount: Money [1] +dispatch() +close() +updatepricefor(product) 1 * Customer #number: String [1] #name: Name [1] #address: String [0..1] #getcreditrating() if customer.getcreditrating is "poor" then approved must be true 1 1..* +lineitems {ordered} OrderLine * 1 Product PAGE 51 Corporate Customer +contractnumber: String [1] +contactname: Name [1] +creditrating: String [1] Private Customer +creditcardnumber: String [1] 34

Advantages / disadvantages» Looks nice but cluttered? 6 classes only, 2 without attributes/operations» How can we reduce the amount of information? Reduce the number of classes Reduce the number of associations / generalizations / compositions / aggregations Association classes [see next slide] Reduce information per association Drop names of associations/roles unless meaningful Reduce the number of attributes Reduce information per attribute Multiplicity of [1] can be assumed 35

Association class» OrderLine represents an association between Order and Product No multiplicity: one instance per association No additional associations Order 1 Order * 1..* OrderLine * 1 Product 1..* Product OrderLine 36

Correct or incorrect? Company * Role * Contract 37

Correct or incorrect? Company * Role * Contract No, companies can play multiple roles in the same contract: e.g., supplier and maintenance provider 38

Correct or incorrect? Person * Competency level * Skill 39

Correct or incorrect? Person * Competency level * Skill Yes, for each skill a person would typically have only one competency level. 40

Further simplification» Association is stronger than dependency» We do not need to show both! Order 1 Order * Order * 1..* OrderLine * 1 Product 1..* Product OrderLine 1..* Product OrderLine 41

Simplifying the diagram Order +number: String +placedon: Date +deliveredon: Date [0..1] +approved: Boolean +totalamount: Money +dispatch() +close() +updatepricefor(product) * Customer #number: String #name: Name #address: String [0..1] #getcreditrating() if customer.getcreditrating is "poor" then approved must be true 1 OrderLine * 1..* Product Corporate Customer +contractnumber: String +contactname: Name +creditrating: String Private Customer +creditcardnumber: String PAGE 59 42

43

UML diagram types Classes: Chapter 11.4 of the UML standard. 44