Introduction to Software Engineering. 5. Modeling Objects and Classes

Similar documents
Introduction to Software Engineering. 5. Modeling Objects and Classes

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

OO Analysis and Design with UML 2 and UP

Modellistica Medica. Maria Grazia Pia, INFN Genova. Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico

Unified Modeling Language

Model Driven Development Unified Modeling Language (UML)

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

Ingegneria del Software Corso di Laurea in Informatica per il Management. Introduction to UML

Software Service Engineering

Course "Softwaretechnik" Book Chapter 2 Modeling with UML

Software Engineering from a

SOFTWARE DESIGN COSC 4353 / Dr. Raj Singh

Engineering Design w/embedded Systems

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

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

UML & OO FUNDAMENTALS CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 3 08/30/2011

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

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

1 Reference Material for these slides is taken from many UML reference books. However, the two I most often used are: UML Explained, by Kendall Scott,

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

Software Engineering Lab Manual

Unified Modeling Language (UML) Class Diagram

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

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

Chapter 12. UML and Patterns. Copyright 2008 Pearson Addison-Wesley. All rights reserved

LABORATORY 1 REVISION

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

Introducing the UML Eng. Mohammed T. Abo Alroos

12 Tutorial on UML. TIMe TIMe Electronic Textbook

CISC 322 Software Architecture

Course 3 7 March

MechEng SE3 Lecture 7 Domain Modelling

CHAPTER 1. Topic: UML Overview. CHAPTER 1: Topic 1. Topic: UML Overview

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

UML Diagrams & And Some Of Their Elements

History of object-oriented approaches

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

UNIT I. 3. Write a short notes on process view of 4+1 architecture. 4. Why is object-oriented approach superior to procedural approach?

UML: Unified Modeling Language

Software Development Methodologies

Experiment no 4 Study of Class Diagram in Rational Rose

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

UML & OO Fundamentals. CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 3 09/04/2012

UML Tutorial. Unified Modeling Language UML Tutorial

Object-Oriented Design

OO Techniques & UML Class Diagrams

Unified Modeling Language (UML)

UNIT-II Introduction to UML

UML (Unified Modeling Language)

Object-Oriented and Classical Software Engineering

Software Engineering

Lab Manual. Object Oriented Analysis And Design. TE(Computer) VI semester

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

CMPT 354 Database Systems I

An Introduction To Object Modeling System Concept for Object Modeling The Overall View Components of UML Diagram

Research Review on Basic Principles of Unified Modelling Language

Design and UML Class Diagrams

UNIT 5 - UML STATE DIAGRAMS AND MODELING

Chapter 5: Structural Modeling

The Dynamic Model. An Introduction to UML. Enterprise Architect. by Geoffrey Sparks. All material (c) Geoffrey Sparks

UML Primer. -Elango Sundaram

For 100% Result Oriented IGNOU Coaching and Project Training Call CPD TM : ,

Systems Analysis & Design

Unified Modeling Language

Object-Oriented Systems Development: Using the Unified Modeling Language

Software Development. Modular Design and Algorithm Analysis

Chapter 1: Principles of Programming and Software Engineering

SE 1: Software Requirements Specification and Analysis

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.

UNIT II. Syllabus. a. An Overview of the UML: Visualizing, Specifying, Constructing, Documenting

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

CIS 771: Software Specifications

Unified Modeling Language (UML)

Unified Modeling Language (UML)

Pertemuan 8. Object Oriented Modeling and Design

Basic Structural Modeling. Copyright Joey Paquet,

EECS 4314 Advanced Software Engineering. Topic 03: UML Overview Zhen Ming (Jack) Jiang

Chapter 2: The Object-Oriented Design Process

NOTES ON OBJECT-ORIENTED MODELING AND DESIGN

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

Object-Oriented Systems Analysis and Design Using UML

Modeling Requirements

Index. : (colon), 80 <<>> (guillemets), 34, 56

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

UML. By Somenath Mukhopadhyay.

Data and Process Modelling

UML 2.0 State Machines

Software Engineering

Chapter 2 Entity-Relationship Data Modeling: Tools and Techniques. Fundamentals, Design, and Implementation, 9/e

CSE 308. UML Overview Use Case Diagrams. Reference. Class diagrams. Session 6 UML Intro/Use cases. Robert Kelly, B. Bruegge,

1 Introduction. 1.1 Introduction

Introduction to Unified Modelling Language (UML)

Chapter 10. Object-Oriented Analysis and Modeling Using the UML. McGraw-Hill/Irwin

SOFTWARE ENGINEERING UML FUNDAMENTALS. Saulius Ragaišis.

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.

UML part I. UML part I 1/41

Object Oriented Modeling

UML Modeling. Sumantra Sarkar. 29 th June CIS 8090 Managing Enterprise Architecture

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)

Class modelling (part 2)

Transcription:

Introduction to Software Engineering 5. Modeling Objects and Classes

Roadmap > UML Overview > Classes, attributes and operations > UML Lines and Arrows > Parameterized Classes, Interfaces and Utilities > Objects, Associations > Inheritance > Patterns, Constraints and Contracts 2

Sources > The Unified Modeling Language Reference Manual, James Rumbaugh, Ivar Jacobson and Grady Booch, Addison Wesley, 1999. > UML Distilled, Martin Fowler, Kendall Scott, Addison- Wesley, Second Edition, 2000. 3

Roadmap > UML Overview > Classes, attributes and operations > UML Lines and Arrows > Parameterized Classes, Interfaces and Utilities > Objects, Associations > Inheritance > Patterns, Constraints and Contracts 4

UML What is UML? > uniform notation: Booch + OMT + Use Cases (+ state charts) UML is not a method or process The Unified Development Process is Why a Graphical Modeling Language? > Software projects are carried out in team > Team members need to communicate... sometimes even with the end users > One picture conveys a thousand words the question is only which words Need for different views on the same software artifact 5

Why UML? Why UML? > Reduces risks by documenting assumptions domain models, requirements, architecture, design, implementation > Represents industry standard more tool support, more people understand your diagrams, less education > Is reasonably well-defined... although there are interpretations and dialects > Is open stereotypes, tags and constraints to extend basic constructs has a meta-meta-model for advanced extensions 6

UML History > 1994: Grady Booch (Booch method) + James Rumbaugh (OMT) at Rational > 1994: Ivar Jacobson (OOSE, use cases) joined Rational The three amigos > 1996: Rational formed a consortium to support UML > 1997: UML1.0 submitted to OMG by consortium > 1997: UML 1.1 accepted as OMG standard However, OMG names it UML1.0 > 1998- : Revisions UML1.2-1.5 > 2005: Major revision to UML2.0, includes OCL 7

2000 Addison-Wesley UML Distilled

2000 Addison-Wesley UML Distilled

Roadmap > UML Overview > Classes, attributes and operations > UML Lines and Arrows > Parameterized Classes, Interfaces and Utilities > Objects, Associations > Inheritance > Patterns, Constraints and Contracts 10

Class Diagrams Class diagrams show generic descriptions of possible systems, and object diagrams show particular instantiations of systems and their behaviour. Attributes and operations are also collectively called features. Danger: class diagrams risk turning into data models. Be sure to focus on behaviour 11

Visibility and Scope of Features Stereotype (what kind of class is it?) User-defined properties (e.g., readonly, owner = Pingu ) underlined attributes have class scope + = public # = protected - = private «user interface» Window { abstract } +size: Area = (100, 100) #visibility: Boolean = false +default-size: Rectangle #maximum-size: Rectangle -xptr: XWindow* +display ( ) +hide ( ) +create ( ) -attachxwindow (xwin: Xwindow*)... Don t worry about visibility too early! italic attributes are abstract An ellipsis signals that further entries are not shown 12

Attributes and Operations Attributes are specified as: name: type = initialvalue { property string } Operations are specified as: name (param: type = defaultvalue,...) : resulttype 13

Roadmap > UML Overview > Classes, attributes and operations > UML Lines and Arrows > Parameterized Classes, Interfaces and Utilities > Objects, Associations > Inheritance > Patterns, Constraints and Contracts 14

UML Lines and Arrows Constraint (usually annotated) Association e.g., «uses» Dependency e.g., «requires», «imports»... Realization e.g., class/template, class/interface Aggregation i.e., consists of Navigable association e.g., part-of Generalization i.e., specialization (!) e.g., class/superclass, concrete/abstract class Composition i.e., containment 15

Roadmap > UML Overview > Classes, attributes and operations > UML Lines and Arrows > Parameterized Classes, Interfaces and Utilities > Objects, Associations > Inheritance > Patterns, Constraints and Contracts 16

Parameterized Classes Parameterized (aka template or generic ) classes are depicted with their parameters shown in a dashed box. 17

Interfaces Interfaces, equivalent to abstract classes with no attributes, are represented as classes with the stereotype «interface» or, alternatively, with the Lollipop-Notation : 18

Utilities A utility is a grouping of global attributes and operations. It is represented as a class with the stereotype «utility». Utilities may be parameterized. «utility» MathPack randomseed : long = 0 pi : long = 3.14158265358979 sin (angle : double) : double cos (angle : double) : double random ( ) : double return sin (angle + pi/2.0); NB: A utility s attributes are already interpreted as being in class scope, so it is redundant to underline them. A note is a text comment associated with a view, and represented as box with the top right corner folded over. 19

Roadmap > UML Overview > Classes, attributes and operations > UML Lines and Arrows > Parameterized Classes, Interfaces and Utilities > Objects, Associations > Inheritance > Patterns, Constraints and Contracts 20

Objects Objects are shown as rectangles with their name and type underlined in one compartment, and attribute values, optionally, in a second compartment. At least one of the name or the type must be present. 21

Associations Associations represent structural relationships between objects usually binary (but may be ternary etc.) optional name and direction (unique) role names and multiplicities at end-points 22

Multiplicity > The multiplicity of an association constrains how many entities one may be associated with Examples: 0..1 Zero or one entity 1 Exactly one entity * Any number of entities 1..* One or more entities 1..n One to n entities And so on 23

Associations and Attributes > Associations may be implemented as attributes But need not be Person +parent...... Person parent 24

Aggregation and Composition Aggregation is denoted by a diamond and indicates a part-whole dependency: A hollow diamond indicates a reference; a solid diamond an implementation (i.e., ownership). Aggregation: parts may be shared. Composition: one part belongs to one whole. 25

Association Classes An association may be an instance of an association class: In many cases the association class only stores attributes, and its name can be left out. 26

Qualified Associations A qualified association uses a special qualifier value to identify the object at the other end of the association. NB: Qualifiers are part of the association, not the class 27

Roadmap > UML Overview > Classes, attributes and operations > UML Lines and Arrows > Parameterized Classes, Interfaces and Utilities > Objects, Associations > Inheritance > Patterns, Constraints and Contracts 28

Generalization A subclass specializes its superclass: 29

What is Inheritance For? > New software often builds on old software by imitation, refinement or combination. > Similarly, classes may be extensions, specializations or combinations of existing classes. 30

Generalization expresses... Conceptual hierarchy: > conceptually related classes can be organized into a specialization hierarchy people, employees, managers geometric objects... Polymorphism: > objects of distinct, but related classes may be uniformly treated by clients array of geometric objects Software reuse: > related classes may share interfaces, data structures or behaviour geometric objects... 31

The different faces of inheritance Rectangle Figure Square Square Rectangle Square Rectangle Is-a Polymorphism Reuse 32

Roadmap > UML Overview > Classes, attributes and operations > UML Lines and Arrows > Parameterized Classes, Interfaces and Utilities > Objects, Associations > Inheritance > Patterns, Constraints and Contracts 33

Design Patterns as Collaborations 34

Constraints Constraints are restrictions on values attached to classes or associations. 35

OCL Object Constraint Language > Used to express queries and constraints over UML diagrams Navigate associations: Person.boss.employer Select subsets: Company.employee->select(title= Manager ) Boolean and arithmetic operators: Person.salary < Person.boss.salary www.omg.org 36

Design by Contract in UML Combine constraints with stereotypes: NB: «invariant», «precondition», and «postcondition» are predefined in UML. 37

Using the Notation During Analysis: Capture classes visible to users Document attributes and responsibilities Identify associations and collaborations Identify conceptual hierarchies Capture all visible features During Design: Specify contracts and operations Decompose complex objects Factor out common interfaces and functionalities The graphical notation is only one part of the analysis or design document. For example, a data dictionary cataloguing and describing all names of classes, roles, associations, etc. must be maintained throughout the project. 38

What you should know! > How do you represent classes, objects and associations? > How do you specify the visibility of attributes and operations to clients? > How is a utility different from a class? How is it similar? > Why do we need both named associations and roles? > Why is inheritance useful in analysis? In design? > How are constraints specified? 39

Can you answer the following questions? > Why would you want a feature to have class scope? > Why don t you need to show operations when depicting an object? > Why aren t associations drawn with arrowheads? > How is aggregation different from any other kind of association? > How are associations realized in an implementation language? 40

Attribution-ShareAlike 3.0 You are free: to copy, distribute, display, and perform the work to make derivative works to make commercial use of the work Under the following conditions: Attribution. You must attribute the work in the manner specified by the author or licensor. Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one. For any reuse or distribution, you must make clear to others the license terms of this work. Any of these conditions can be waived if you get permission from the copyright holder. Your fair use and other rights are in no way affected by the above. http://creativecommons.org/licenses/by-sa/3.0/