66
Modern methods in Software Engineering Requirements Analysis www.imit.kth.se/courses/2G1522 1

Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

  • Upload
    phamdan

  • View
    223

  • Download
    4

Embed Size (px)

Citation preview

Page 1: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Modern methods in Software Engineering

Requirements Analysis

www.imit.kth.se/courses/2G1522

1

Page 2: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Literature used

•  Text book

Chapter 5

2

Page 3: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Content

•  Model and reality •  Activities during object modeling •  Class identification approaches •  Aspect Oriented Programming

3

Page 4: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Why models? •  Reality R: Real Things, People, Processes

happening during some time, Relationship between things

•  Model M: Abstractions from (really existing or only thought of ) things, people , processes and relationships between these abstractions.

•  We use models –  To abstract away from details in the reality, so we can

draw complicated conclusions in the reality with simple steps in the model

–  To get insights into the past or presence –  To make predictions about the future

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

4

Page 5: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Models Models of reality cannot be true •  A model is always an approximation

–  We must say “according to our knowledge”, or “with today’s knowledge”

•  Popper (“Objective Knowledge): –  We can only build models from reality, which are “true” until, we have found a counter example (Principle of Falsification – demonstrating that relevant details of model are presented incorrectly or not presented at all)

•  And even then we might stick with the model (“because it works quite well in most settings”)

•  The falsification principle is the basis of software development –  The goal of prototypes, reviews and system testing is to

falsify the software system Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

5

Page 6: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Models •  Relationships, which are valid in reality R, are also

valid in model M. –  I : Mapping of real things in reality R to abstractions in the

model M (Interpretation) –  fM: relationship between abstractions in M –  fR: relationship between real things in R

fM

fR

M!M!

R! R!I I

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

6

Page 7: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Models •  Modeling is relative. We can think of a model as

reality and can build another model from it (with additional abstractions)

fM1

fR

M1!M1!

R! R!

Requirements Elicitation I1

M2!M2!

Analysis I2

fM2

….!The development of !

Software-Systemes is a !Transformation of !

Models:! Analysis, Design,!

Implementation,Testing!

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

7

Page 8: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Products of Requirements Elicitation and Analysis

Analysis

functional model

nonfunctional requirements

analysis object model

Requirements elicitation

dynamic model

Requirements

Analysis Model

Specification

System design

Object design

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

8

Page 9: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Analysis model

analysis model:Model

dynamic model:Model

object model:Model

functional model:Model

use case diagram:View

class diagram:View

statechart diagram:View

sequence diagram:View

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

9

Page 10: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

When is a model dominant? •  Object model: The system has objects with nontrivial state. •  Dynamic model: The model has many different types of

events: Input, output, exceptions, errors, etc. •  Functional model: The model performs complicated

transformations (e.g. computations consisting of many steps).

•  Which of these models is dominant in the following three cases? –  Compiler –  Database system –  Spreadsheet program

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

10

Page 11: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

When is a model dominant? •  Compiler:

–  The functional model most important. –  The dynamic model is trivial because there is only one type input

and only a few outputs. •  Database systems:

–  The object model most important. –  The functional model is trivial, because the purpose of the

functions is usually to store, organize and retrieve data. •  Spreadsheet program:

–  The functional model most important. –  The dynamic model is interesting if the program allows

computations on a cell. –  The object model is trivial, because the spreadsheet values are

trivial and cannot be structured further. The only interesting object is the cell.

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

11

Page 12: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Pieces of an Object Model •  Classes

•  Associations (Relations) –  Generic associations –  Canonical associations

•  Part of- Hierarchy (Aggregation) •  Kind of-Hierarchy (Generalization)

•  Attributes –  Application specific

•  Operations –  Generic operations: Get/Set, General world knowledge,

design patterns –  Domain operations: Dynamic model, Functional model

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

12

Page 13: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Object Modeling •  Main goal: Find the important abstractions •  What happens if we find the wrong abstractions?

–  Iterate and correct the model •  Steps during object modeling

–  1. Class identification •  Based on the fundamental assumption that we can find abstractions

–  2. Find the attributes –  3. Find the methods –  4. Find the associations between classes

•  Order of steps –  Goal: get the desired abstractions –  Order of steps secondary, only a heuristic –  Iteration is important

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

13

Page 14: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Pieces of an Dynamic Model

•  Sequence diagrams – interactions between objects

•  State-Chart diagrams – behavior of individual objects

14

Page 15: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Analysis activities •  Identify classes/objects •  Identify associations, identify aggregates •  Identify attributes •  Modeling inheritance relationships •  Map use cases to objects with Sequence

Diagrams •  Model state-dependent behavior of individual

objects •  Reviewing the analysis model

15

Page 16: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Class Identification •  Class identification is crucial to object-

oriented modeling •  Basic assumption:

–  1. We can find the classes for a new software system

–  2. We can identify the classes in an existing system

•  Why can we do this? – Philosophy, science, experimental evidence

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

16

Page 17: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Class identification •  Approaches

–  Application domain approach: •  Ask application domain expert to identify relevant abstractions

–  Syntactic approach: •  Use noun-verb analysis (Abbot’s technique) to identify components

of the object model (from descriptions or from use cases - extract participating objects from flow of events)

–  Common class pattern approach •  Use generic classification theory of objects

–  Design patterns approach •  Use reusable design patterns

–  Component-based approach: •  Identify existing solution classes

–  Object types approach

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

17

Page 18: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Mapping parts of speech to object model components [Abbott, 1983]

!Part of speech! Model component! Example!

!Proper noun! object! Jim Smith!

!Improper noun! class! Toy, doll!

!Doing verb! method! Buy, recommend!

!being verb! inheritance ! is-a (kind-of)!

!having verb! aggregation! has an!

!modal verb! constraint! must be!

!adjective! attribute! 3 years old!

!transitive verb! method! enter!

!intransitive verb! method (event)! depends on!

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

18

Page 19: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Example •  The customer enters the store to buy a toy. •  It has to be a toy that his daughter likes and it must cost

less than 50 Euro. •  He tries a videogame, which uses a data glove and a

head-mounted display. He likes it.

An assistant helps him. The suitability of the game depends on the age of the child. His daughter is only 3 years old. The assistant recommends another type of toy, namely the boardgame “Monopoly".

Flow of events:

Is this a good use!Case?!

The use case should !terminate with the !

customer leaving the store!

Not quite!!

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

19

Page 20: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Textual analysis (Abbot‘s technique) Grammatical construct UML Component

Concrete Person, Thing Object noun class

verb Operation

Classifying verb Inheritance

Possessive Verb Aggregation

modal Verb Constraint

Adjective Attribute

Intransitive verb Operation (Event)

Example “Monopoly" “toy"

“enters"

“is a" ,“either..or", “kind of…" "Has a ", “consists of"

“must be", “less than…"

"3 years old"

“depends on…."

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

20

Page 21: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Generation of a class diagram from flow of events

•  The customer enters the store to buy a toy. It has to be a toy that his daughter likes and it must cost less than 50 Euro. He tries a videogame, which uses a data glove and a head-mounted display. He likes it.

customer store enters

Customer

?

enter()

toy

daughter suitable

*

less than 50 Euro

store

enter()

daughter age

toy

buy()

videogame

boardgame

toy

videogame

daughter

Flow of events:

toy price buy()

buy

An assistant helps him. The suitability of the game depends on the age of the child. His daughter is only 3 years old. The assistant recommends another type of toy, namely a boardgame. The customer buy the game and leaves the store

type of toy

age

boardgame

depends !

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

his

21

Page 22: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Noun-phrase approach

•  Irrelevant classes are those that are outside the problem domain

•  Relevant classes are those that manifestly belong to the problem domain

•  Fuzzy classes are those that the analyst cannot confidently and unanimously classify as relevant

22

Page 23: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Common class pattern approach

•  Concept class – a concept is a notion that a large community of people share and agree on

•  Events class – an event is something that does not take time relative to our time scale

•  Organization class – organization is any kind of purposeful grouping or collection of things

•  People class – "people" is understood here as a role that a person plays in the system

•  Places class – places are physical locations relevant to the information system 23

Page 24: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Rumbaugh et al. (1999) propose a different classification scheme

•  physical class (e.g. Airplane); •  business class (e.g. Reservation); •  logical class (e.g. FlightTimetable); •  application class (e.g. ReservationTransaction); •  computer class (e.g. index); •  behavioral class (e.g. ReservationCancellation).

24

Page 25: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Finding Participating Objects in Use Cases

•  Pick a use case and look at its flow of events –  Find terms that developers or users need to clarify in

order to understand the flow of events –  Look for recurring nouns (e.g., Incident), –  Identify real world entities that the system needs to

keep track of (e.g., FieldOfficer, Dispatcher, Resource), –  Identify real world procedures that the system needs to

keep track of (e.g., EmergencyOperationsPlan), –  Identify data sources or sinks (e.g., Printer) –  Identify interface artifacts (e.g., PoliceStation)

•  Be prepared that some objects are still missing and need to be found:

•  Model the flow of events with a sequence diagram •  Always use the user’s terms

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

25

Page 26: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

The use-case driven approach

•  The graphical model of use cases is supplemented with narrative descriptions and with activity and interaction models

•  In reality, the use-case driven approach bears some similarity to the noun phrase approach.

•  Being a bottom-up approach, it relies for its accuracy on the completeness and correctness of the use-case models

•  Partial use-case models result in incomplete class models.

26

Page 27: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

The CRC (class-responsibility-collaborators) approach

•  The CRC approach involves brainstorming sessions, made easy by the use of specially prepared cards

•  The cards have three compartments: –  Class name –  Responsibilities –  Collaborations

•  The CRC approach is an animated process during which the developers "play cards“

•  They fill cards with class names and assign responsibilities and collaborators while "executing" a processing scenario (e.g. a use-case scenario).

27

Page 28: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

ReportEmergency: Managing Interactions among Objects with CRC Cards

ReportEmergencyControl

Responsibil ities

Collects input from Field-officerControls sequence of forms during emergency reporting

Collaborators

EmergencyReportFormEmergencyReportAcknowledgementNotice

Incident

Responsibil ities

Track al l information related to a single inci-dent.

Collaborators

Resource

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

28

Page 29: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Mixed approach •  In practice, the process of class discovery is likely to be guided

by different approaches at different times •  The process is neither top-down nor bottom-up; it is middle-out. •  A possible scenario

–  The initial set of classes may be discovered from the generic knowledge and experience of analysts

–  The common class patterns approach can provide additional guidance –  Other classes may be added from the analysis of high level descriptions

of the problem domain using the noun phrase approach –  If use-case diagrams are available, then the use-case driven approach can

be used to add new and verify existing classes –  Finally, the CRC approach will allow brainstorming the list of classes

discovered so far.

29

Page 30: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Do not use concepts of solution domain in analysis model

UniversalTime

TimeZone

Location

TimeZoneDatabase

GPSLocator

UserId

Software classes that should not be represented in the analysis object model.

Domain concepts that should be represented in the analysis object model.

Refers to how time zones are stored (design decision).

Denotes to how location is measured (design decision). Refers to an internal mechanism for identifying users (design decision)

30

Page 31: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Class Identification

– Design patterns approach (Apply design knowledge):

•  Distinguish different types of objects •  Apply design patterns

– Component-based approach: •  Identify existing solution classes

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

31

Page 32: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Object Types •  Entity Objects

–  Represent the persistent information tracked by the system (Application domain objects, “Business objects”)

•  Boundary Objects –  Represent the interaction between the user and the system

•  Control Objects: –  Represent the control tasks performed by the system

•  Having three types of objects leads to models that are more resilient to change. –  The interface of a system changes more likely than the control –  The control of the system change more likely than the application

domain

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

32

Page 33: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Year!

Month!

Day!

ChangeDate!Button!

LCDDisplay!

Entity Objects! Control Objects! Boundary Objects!

Object Types

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

33

Page 34: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Naming of Object Types in UML

•  UML provides several mechanisms to extend the language •  UML provides the stereotype mechanism to present new

modeling elements

<<Entity>>!Year!

<<Entitity>>!Month!

<<Entity>>!Day!

<<Control>>!ChangeDate!

<<Boundary>>!Button!

<<Boundary>>!LCDDisplay!

Entity Objects! Control Objects! Boundary Objects!

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

34

Page 35: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Recommended Naming Convention for Object Types

•  To distinguish the different object types on a syntactical basis, suffixes can be used:

–  Objects ending with the “_Boundary” suffix are boundary objects –  Objects ending with the “_Control” suffix are control objects

•  Entity objects do not have any suffix appended to their name.

Year!

Month!

Day!

ChangeDate_Control!

Button_Boundary!

LCDDisplay_Boundary!

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

35

Page 36: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Identifying Entity Objects

•  Heuristics to be used together with Abbot’s heuristics: –  Terms that developers or users need to clarify in order

to understand the use case –  Recurring nouns in the use cases –  Real-world entities that the system needs to track –  Real-world activities that the system needs to track –  Data sources or sinks

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

36

Page 37: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Identifying Boundary Objects •  Heuristics for identifying boundary objects

–  Identify user interface controls that the user needs to initiate the use case

–  Identify forms the users needs to enter data into the system –  Identify notices and messages the system uses to respond to the

user –  When multiple actors are involved in a use case, identify actor

terminals to refer to user interface under construction –  Do not model the visual aspects of the interface with boundary

objects (user mock-ups are better suited for that) –  Always use the end user's terms for describing interfaces; do not

use terms from the solution or implementation domains.

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

37

Page 38: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Identifying control objects

•  Heuristics for identifying control objects –  Identify one control object per use case. –  Identify one control object per actor in the use case. – The life span of a control object should cover the

extent of the use case or the extent of a user session.

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

38

Page 39: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Identifying associations

* 1 writes author document

1

1 1

1

triggers reports

FieldOfficer EmergencyReport

Incident

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

Heuristics for identifying associations • Examine verb phrases (e.g., has, is part of, manages, reports to, is triggered by, is contained in, talks to, includes). • Name associations and roles precisely. • Use qualifiers as often as possible to identify namespaces and key attributes. • Do not worry about multiplicity until the set of associations is stable. • Too many associations make a model unreadable.

• Eliminate any association that can be derived from other associations.

39

Page 40: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Identifying Attributes

EmergencyReport

emergencyType:{fire,traffic,other} location:String description:String

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

Heuristics for identifying attributes • Examine possessive phrases or adjective phrases. • Represent stored state as an attribute of the entity object. • Describe each attribute. • Do not represent an attribute as an object; use an association instead • Do not waste time describing fine details before the object structure is stable.

40

Page 41: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Who uses class diagrams? •  Purpose of Class diagrams :

–  The description of the static properties of a system (main purpose)

•  Who uses class diagrams? –  The customer and the end user are often not interested

in class diagrams. They usually focus more on the functionality of the system.

–  The application domain expert uses class diagrams to model the application domain

–  The developer uses class diagrams during the development of a system, that is, during analysis, system design, object design and implementation.

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

41

Page 42: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Different users of class diagrams •  According to the development activity, the

developer plays different roles. – Analyst – System-Designer, – DetailedDesigner –  Implementor.

•  In small systems some of the roles do not exist or are played by the same person.

•  Each of these roles has a different view about the models.

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

42

Page 43: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Why do we distinguish these different users of class diagrams?

•  Models often don‘t distinguish between application classes (“address book") and solution class (“array", “tree"). –  Reason: Modelling languages like UML allow the use of both types of

classes in the same model. –  Preferred : No solution classes in the analysis model.

•  Many systems don‘t distinguish between specification and implementation of a class. –  Reason: Object-oriented programming languages allow the simultaneous

use of specification and implementation of a class. –  Preferred: The object design model does not contain implementations.

•  The key for creating high quality software systems is the exact distinction between –  Application and solution domain classes –  Interface specification and implementation specification

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

43

Page 44: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Dynamic Modeling •  Dynamic model consists of:

–  A collection of multiple state chart diagrams, one state chart diagram for each class with important dynamic behavior.

–  A collection of communication diagrams between objects •  Purpose:

–  Detect and supply methods for the object model –  Assign responsibilities to individual classes and –  identify new classes, associations, and attributes to be added

to the analysis object model •  How do we do this?

–  Start with use case or scenario –  Model interaction between objects => sequence diagram –  Model dynamic behavior of a single object => statechart diagram

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

44

Page 45: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Sequence Diagram •  From the flow of events in the use case or scenario proceed

to the sequence diagram •  A sequence diagram is a graphical description of objects

participating in a use case or scenario using a graph notation

•  Relation to object identification: –  Objects/classes have already been identified during object

modeling –  New objects are identified as a result of dynamic modeling

•  Heuristic: –  An event always has a sender and a receiver. –  The representation of the event is sometimes called a message –  Find objects for each event/message

=> These are the objects participating in the use case

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

45

Page 46: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

An Example •  Flow of events in a “GetPosition” use case :

1. Establish connection between smart terminal and

onboard computer

2. Establish connection between onboard computer and server at Headquarter

3. Get current maintenance expert position and store in smart terminal

•  Which are the objects?

46

Page 47: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Sequence Diagram for “GetPosition” Smart Terminal Onboard Computer Server

Establish Connection Establish Connection

Accept Connection

Accept Connection

Get Position

“500,575,300”

1. Establish connection between smart terminaland onboard computer��� 2. Establish connection between onboard computer and server at headquarter��� 3. Get current position and store on smart card

time Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

47

Page 48: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Heuristics for Sequence Diagrams •  Layout:

–  1st column: Should correspond to the actor who initiated the use case

–  2nd column: Should be a boundary object –  3rd column: Should be the control object that manages the rest of

the use case •  Creation:

–  Control objects are created at the initiation of a use case –  Other then initial Boundary objects are created by control objects

•  Access: –  Entity objects are accessed by control and boundary objects, –  Entity objects should never call boundary or control objects: This

makes it easier to share entity objects across use cases and makes entity objects resilient against technology-induced changes in boundary objects.

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

48

Page 49: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Is this a good Sequence Diagram? Smart Terminal Onboard Computer server

Establish Connection Establish Connection

Accept Connection

Accept Connection

Get Position

“500,575,300”

• First column is not the actor

• It is not clear where the boundary object is

• It is not clear where the control object is

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

49

Page 50: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Sequence Diagram for “GetPosition” Smart Terminal Onboard Computer Server

Establish Connection

Establish Connection

Accept Connection

“500,575,300”

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

Driver ControlSC

Accept Connection

Get Position

«new»

50

Page 51: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Fork Diagram

•  Much of the dynamic behavior is placed in a single object, usually the control object. It knows all the other objects and often uses them for direct questions and commands.

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

51

Page 52: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Stair Diagram

•  The dynamic behavior is distributed. Each object delegates some responsibility to other objects. Each object knows only a few of the other objects and knows which objects can help with a specific behavior.

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

52

Page 53: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Fork or Stair?

•  Decentralized control structure –  The operations have a strong connection –  The operations will always be performed in the same

order

•  Centralized control structure better support of change (because of encapsulation in one object) –  The operations can change order –  New operations can be inserted as a result of new

requirements

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

53

Page 54: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

State Chart Diagram vs Sequence Diagram

•  Sequence diagrams help to identify – The temporal relationship between objects over

time –  Sequence of operations as a response to one ore

more events •  State chart diagrams help to identify:

– Changes to an individual object over time

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

54

Page 55: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Modeling State-Dependent Behavior of Individual Objects (Incident)

Active

Inactive Closed Archived

all

when d ate > 1yr.

resources submitted reports

Reported Assessment

Disengagement Response

field officer arrives on site

field officer releases resources

dispatcher allocates resources field officer requests

additional resources

all resources deallocated

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

55

Page 56: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Modeling Checklist for the Review •  Is the model correct? A model is correct if it represents the client’s view of the the system:

Everything in the model represents an aspect of reality

•  Is the model complete? Every scenario through the system, including exceptions, is described. •  Is the model consistent? The model does not have components that contradict themselves (for

example, deliver contradicting results) •  Is the model unambiguous? The model describes one system (one reality), not many •  Is the model realistic? The model can be implemented without problems

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

56

Page 57: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Summary 1. What are the transformations?

Create scenarios and use case diagrams

Talk to client, observe, get historical records, do thought experiments 2. What is the structure of the system?

Create class diagrams Identify objects. What are the associations between them? What is their multiplicity? What are the attributes of the objects? What operations are defined on the objects?

3. What is its behavior? Create sequence diagrams

Identify senders and receivers Show sequence of events exchanged between objects. Identify event dependencies and event concurrency.

Create state diagrams Only for the dynamically interesting objects.

Dynamic Modeling

Functional Modeling

Object Modeling

Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java

57

Page 58: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Aspect-Oriented Programming (AOP)

•  Some problems are not attached to any particular domain but they are spread across them

•  OOP – assumes knowledge of all needed interfaces for the developer and interfaces are not easy to change

•  OOP composes components vertically while we might need to compose them horizontally

Adopted from Ivan Kiselev. Aspect-Oriented Programming with AspectJ

58

Page 59: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Fruit and Gadget hierarchy Fruit

+peelable +color +ripeness

+pick() +refrigerate()

Gadget

+color

+turnOn() +turnOff()

Grapes

+peelable +collor +ripeness

+pick() +refrigerate()

Orange

+peelable +collor +ripeness

+pick() +refrigerate()

Wireless

+color

+acquireSignal() +receive()

Wired

+connectionType

+isConnected() +reset()

Adopted from Ivan Kiselev. Aspect-Oriented Programming with AspectJ

59

Page 60: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Fruits and Gadgets as commodities

Fruit

Packaged item

Commodity

Storage Unit

+wrapper +numberPerBox

+price

-SKU

+buy() +sell()

+store() +retrieve()

Gadget

Adopted from Ivan Kiselev. Aspect-Oriented Programming with AspectJ

60

Page 61: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Crosscutting concerns

Adopted from Ivan Kiselev. Aspect-Oriented Programming with AspectJ

Grapes

+makeWine() +getSugar()

+drawLabel() +weigh()

+buy() +sell()

+store() +retrieve()

Orange

+squeeze() +dryPeel()

+drawLabel() +weigh()

+buy() +sell()

+store() +retrieve()

Wireless

+acquireSignal() +receive()

+drawLabel() +weigh()

+buy() +sell()

+store() +retrieve()

Wired

+isConnected() +reset()

+drawLabel() +weigh()

+buy() +sell()

+store() +retrieve()

Packed Item

Storage Unit

Commodity

61

Page 62: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Room, Reservation and Payment

Room

checkAvailability()

assignCustomer()

removeCustomer()

Reservation

create()

consume()

Payment

createBill()

payBill()

Book room

Check in customer

Check out customer

Adopted from Jacobson, Ng. Aspect-Oriented Software Engineering

62

Page 63: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

A Simplified Example

Reservation

create()

consume()

Class Aspect

HandleWaitinglist

Reservation with handling waiting list

63

Page 64: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Implementation

•  Join Points – special well-defined points in the program flow where horizontal extension/bundling appears in the code

•  Pointcuts – predicates that match joint points

•  Advices – a code which is executed when a given pointcut is reached

Adopted from Ivan Kiselev. Aspect-Oriented Programming with AspectJ

64

Page 65: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Example continue class Reservation { public void create { ... if(theRoom.getQuantityAvalable()<=0){

throw new NoRoomException() { ...}

aspect HandleWaitingList { ... pointcut makingReservation(): execution(void Reservation.create()); after throwing (NoRoomException e): makingReservation(){ //code to add customer into waiting list

... }

65

Page 66: Modern methods in Software Engineering Requirements …misha/ID2207/2014/lectures/Req... · falsify the software system ... – Compiler – Database system ... • It has to be a

Next lecture

•  Text book Chapters 6 & 7

66