1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory ->...

57
1 Modelling Modelling III III

Transcript of 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory ->...

Page 1: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

1

ModellingModelling III III

Page 2: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

2

Objects

• Object – direct relationship with the real world

• Object– memory -> data -> Attributes– processes -> Operations -> Messages

• Object - Organization – Hierarchy– aggregation– generalization

Page 3: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

3

Object Orientation

• Most famous:– Booch– OMT– Jacobson

Page 4: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

4

UMLBirth

• Several methods and techniques for OO, with many common aspects but using different notations

• Difficult to learn, to apply, to build and to use tools

• Diferences among different approaches (authors)

There was the need for a standard notation

Page 5: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

5

UML

• “Unified Method”• Grady Booch e Jim Rumbaugh

• First presented at OOPSLA’95

• Rational Software• Grady Booch, Jim Rumbaugh e Ivar Jacobson

• Rational Rose CASE tool

Page 6: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

6

UML

It is a Modelling language not a method !

• A method consists of notation language + process

• The proposed process is called Objectory

• We can use UML regardless the process we use

Page 7: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

7

UMLBasic Representation:

• Static Model– ERD evolution

• Internal Dynamic Model– Data Flow – State Machines

• External Dynamic Model– use cases– Languages for interconecting objects

Page 8: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

8

UML - Diagrams

• Use Case Diagrams

• Static Structure Diagrams

• Use Case Diagrams– Actors and their connections with

the system

• Textual description for the Use Case

• Class Diagram– Static Structure for the system

classes

• Object Diagram– Simplify the class diagram

Page 9: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

9

UML - Diagrams

• State Diagram • State Diagram– Possible states an object may have and

events that cause state change

– Activity Diagram

– Sequential flow of activities

Page 10: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

10

UML - Diagrams

• Interaction Diagrams

• Implementation Diagrams

• Sequence Diagram– Dynamic collaboration expressed as

messages exchanges among objects triggered by a function or a sequence in time

• Collaboration Diagram– Dynamic Collaboration using interaction

among objects (context)

• Component Diagram– Physical structure of the code in the form of

code components

• Distribution Diagram– Hardware and Software Physical

Architecture

Page 11: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

11

Use Cases

Sequence

Colaboration

Classes

States

Activity(object behavior,

operation algorithms)

Components

Distribution

Activity(work flow, use

cases)

Requriements Design Implementation

UML - Diagrams

Page 12: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

12

Use Case

Print Receipt

Saleman Make a Sale

Finance System

<<extend>>

Page 13: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

13

Use Case• An Use Case performs a broader aspect

of the product functionality:– Must produce one or more benefits for the

client or users– represent:

• User interaction

• User manual auxiliar

• Test cases

Filho, W.P.P em “Engenharia de Software: Fundamentos, Métodos e Padrões”

Page 14: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

14

Use Case

• Textual Part– Use Case << name>>

• pre-condition• Main flow • sub-flow<<name>>• Alternative flow

– pre-condition

– stepsFilho, W.P.P em “Engenharia de Software: Fundamentos, Métodos e Padrões”

Page 15: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

15

Use Cases

Filho, W.P.P em “Engenharia de Software: Fundamentos, Métodos e Padrões”

Open Cash Register

Manager

Close cash register

Stock Manager

Salesman

Manage stock Manually

Make a sale

Finance System

Exemplo:

Page 16: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

16

Use Cases • Example:

– Use Case << Make a Sale>>• pre-conditions: Every Product on sale must have been previously

registered in the system. The system must be in the Sale mode

• Main flow– Salesman start the sale.

– The System generates a code for the sale operation

– For each item to be sold call the sub-flow Register

– Salesman register form of payment

– Salesman finishes sale

– For each item call the sub-flow Print Receipt Line

Filho, W.P.P em “Engenharia de Software: Fundamentos, Métodos e Padrões”

Page 17: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

17

Use Cases • Identifying actors;

– Who is interested in the requirements– Who will benefit from the product;– Who will give information to the software;– Who will use the software;– Who will remove information from the software.

• Identifying use cases:– What are the actors’ tasks ;– Which information each actor creates, stores, consults,

changes or removes;– Which information each use case creates,consults, changes or

removes.

Page 18: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

18

Use Cases

• Determining use case flow– When and how a use cases starts.

– How the use case interacts with the actors.

– Standard Sequences for steps for a use case.

– Exceptions Sequences and alternative sequences for a use case.

Page 19: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

19

Class Diagrams

• Describe system objects and their static relations

• Objects can be part of the real world or conceptual entities

• Objects are connected to other objects through relationships (association, agregation…)

Page 20: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

20

Class/Object

• Class:• Describe a set of objects that share the same

properties (Attributes), behavior (operation), relationships with other objects and semantics

• Object:• An Object is an instance or occurrence of a class

Page 21: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

21

Class / Object

car B

instanciation

instanciationcar A

Properties: Fuel capicityKm/galonavailabilitykm

Behavior:travelrefuel

Page 22: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

22

Car FuelCapacity: Integerkmpergalon: Realavailability: RealKm: Integer

travel (Kms: Real)Refuel (quantity: Real)

name

attributes

operations

Class

Page 23: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

23

Class whit attributes

Car - FuelCapcity: Integer- Kmpergalon: Real- availability: Real = 0- km: Real = 0

...

rj5015: Car FuelCapacity: 200kmpergalon: 40Availability: 40km: 1400

Objeto com valores

Class

• Attributes• Examples:

Page 24: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

24

Inheritance • Inheritance

• A subclass inherits attributes, operations, state diagram and associations from a superclass

• Inherited properties may be reused from the superclass or redefined in the subclass

• New properties can be added to the subclass

• Can be• Simple: only ine superclass

• Multiple: more tha one superclass

Page 25: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

25

Inheritance

• Multiple• A class inherits attributes, operations and

association from multiple classes

• Offer a greater modelling power but leads to a greater complexity

Page 26: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

26

Example

• Multiple

Vehicle

land water

Car Amphibian Boat

Page 27: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

27

Inheritance

Employee

YeartoDate: Real

calculatePay() {abstract}

MonthlyBasis

Normalhours: RealExtraHours: Real

computarPagamento()

HourBasis

Normalhours: RealExtraHours: Real

calculatePay()

Page 28: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

28

Class Schema • Example: Company

Employee

Company Managers

Association

Agregation

HourBasis MonthlyBasis

Generalization

Class0..N

10..N

Project

Employee schedule

Page 29: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

29

Problems with OO

• Disadvantages (Jackson):– The idea of objects comes from programming

languages and it is not suitable to most of the individuals in a real worlds.

• When have someone sent a message to the paycheck?

• When have a doctor sent a message to Patient’s Record?

Page 30: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

30

Communication

• It is necessary to have a good communication between user/stakeholder and developers

Compreender modelo

AnlysisIs my understanding (vision) correct?

CenáriosDomínio do problemaProblem Domain

Understand the Models

Scenarios

Page 31: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

31

Scenarios• Easy to understand (written using the problem

language)• Help to unify criteria• Stimulate thinking• Help with training• Help on tracking/traceability• Help identifying Non-Functional Requirements

Scenarios are situations

Page 32: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

32

Scenarios

Mundo Real

Universo de Informações

Situações

Lista de Situações

Real World

Universe of Discourse

Situations

List of Situations

Page 33: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

33

Scenarios

• Situation’s Characteristics – Purpose – A situation deals with the satisfaction of a goal.– Actors – A situation encompass a certain and identifiable numbers of

actors (people or devices within organizations).– Resources – Elements that are necessary in one particular situation.– Time – represent a specific moment.– Place – Situations take place within a geographical context.– Constraints – The might have pre-conditions to a situation to happen. – Independent – need to be understood alone.– Inter-related – Are related to other situations, although still independent.– Concrete – Are anchored in reality.– Alternatives – May lead to alternative actions.

Page 34: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

34

Write Scenarios

• Describe situations of the macrosystem

• Describe situations and their relationship with the system-to-be

• May be used to describe interaction between system components

• Use a semi-structured natural language

Page 35: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

35

Scenarios

Page 36: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

36

Why Semi-Structured?

• Avoid confusion

• Provide an homogeneous description style

• Works as a reminder of the several aspects that might be considered within the scenario

• Facilitates to have it validated with the users/stakeholders

Page 37: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

37

Scenarios• Title: Store checks client’s registration• Objective : Verify if information on client’s registration are correct• Context: Client hand over client’s registration and show a photo id • Actors: Store, Client.• Resources: photo id, client’s registration • Episodes

– Store fills up blank spaces in client’s registration using the initial “NE” (Non-existent)

– Stores verify id number on client’s registration against the one in the photo id

– Constraint: id number must comply with standards– Store verify address and phone number calling the number in client’s

registration

Page 38: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

38

Scenarios• Title: Add Book Exemplar to library collection • Objective: Book Exemplar belongs to library collection • Context: Number of Book exemplars available on library collection is not

sufficient• There is enough physical space to store new book exemplar• Book exemplar can be bought or donated• Library clerk is always present

• Library Management System is working

• Actors: Library clerks • Resources: Book Exemplar, book, library collection, library management system• Episodes• 1 Library clerk gets book exemplar to be added to library collection

• 2. If book data is not yet filed in the library management system, library clerk must file book in library collection

• 3 Library clerk file book exemplar in the library management system• 4 Library clerk reserve a physical space to place book exemplar

according to information retrieved from the library management system,• 5. Library Clerk place book exemplar in the correct physical space

Page 39: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

39

Identifying Scenarios

• List Situations– 1. Is there a goal? Is it general (abstract)

enough)? Are there different outputs or is it a sole case?

– 2. Who is involved? Are there other important artifacts or important structures?

– 3. Are there any information or physical elements that are important to this situation?

– 4. Organize identified situations in a list.

Page 40: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

40

Fill in the scenarios

• Don’t Guess !!! Stick to what you know and can validate

• Use the application vocabulary (LEL)

• Using the scenario grammar fill in the candidate scenarios (pair programming with clients is always best)

Page 41: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

41

Notation• Title

• [ Sentence | ( [ Actor | Resource ] + Verb + Predicate ) ]

• Example: Store checks client’s registration

• Objective• [ [ Subject ] + Verb + Predicate ]]

• Example:

• Verify if information on client’s registration are correct Where:

+ - composition{x} – zero or more occurrences of x( ) - group| - or[ ] - optional

Page 42: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

42

Notation

• Context– The context is described detailing time, place

and pre-conditions. At least one of them should appear

“Client hand over client’s registration and show a photo id “

Page 43: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

43

Notation

• Where– local is Phrase +

{Constraint}

– Time is Phrase + {Constraint}

– Pre-condition is

• [Subject| Actor| Resource] + Verb + Predicate + {Restriction}

Page 44: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

44

Notation

• Resource– Relevant Physical elements or information that

should be available to the scenario

• [ Substantive + {Constraint} ]

Page 45: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

45

Notation

• Episodes– Main course of action– Includes variations and alternatives– Exceptions may happen, enforcing the presence

of obstacles to the goals (objectives)– Exceptions may be simple actions but can also

be other scenarios SUB SCENARIO

Page 46: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

46

Notation

• Episodes– There are 3 types of episodes

• Simple – needed to complete the scenario

• Conditionals – depend on essential conditions (If .. Then)

• Optional – May happen or not depending on the course of action

Page 47: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

47

Style

• Short phrases

• Try to avoid more than one verb per phrase

• The objective must be concrete and precise

• At least one of the components for the context must be filled

• Resources must be those directly involved in the episodes. Avoid trivial things

Page 48: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

48

Requirements Sentences• The system must + [verb + object | verbal phrase ] + [agent

complement| null] + [conditions | null]

• Three classes of sentences: (Input, Output, State change}

• Verb is a simple verb which express the requirements functionality

• Verbal phrase is a phrase which expresses the requirements functionality

• Agent Complement is the identification for an agent related with the requirement. Sometimes this complement may be described by the direct object. An agent can be a person, an organization, a group or a device external to the software

• Sentences can be : Functional, non-functional and reverse

Page 49: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

49

Requirements Sentences• The system must produce a receipt for the client

• The system must produce a receipt in less than 2 seconds

• The system must register the client if the client has a photo id

• The system must change an available tape into a rented tape when a client rent a tape

• The system must register library clerks

• The system must not allow a book to be reserved for more than 2 weeks

Page 50: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

50

Organization• Lexicon --> hypertext

• Scenarios --> Relations (complement, pre-condition, equivalent, exception, sub-set, possible, precedence, inclusion).

• Sentences (numerical itemization, chapters)

Page 51: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

51

OrganizationScenarios

Include client

Exclude client

Change clientinformation

Ask for quote

Change quote

Calculate quote

Approve quote

Fill orderform

Emit order form

Cancel form

Emit invoice

Receive payments

ComplementPre conditionEquivalenceexception

LEGEND

Page 52: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

52

Storage• To be helpful scenarios must be organized in such

a way that makes it easier to find it when needed• We need

– Classification, – Indexing and– Presentation.

• Facet schemes (Reuse) : Functional Facets (function, object, way), Non-Functional Facet (type of the system, functional area, context)

Page 53: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

53

Lexicon• Identify symbols

– Apply elicitation technique

– list

• Classify symbols

• Describe symbols– Apply elicitation technique

– Follow rules

– Gather inputs

• Verify

• Validate

Page 54: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

54

Scenarios• Derivate

– identify actors

– identify scenarios

– create candidates

• Describe

– Use representation

– Follow tips

– gather scenarios

• Organize

– reorganize

– Define

– integrate

• Verify

• Validate

Page 55: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

55

Scenarios

Page 56: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

56

Scenarios• Short phrases• Maximize the use of LEL symbols• Use only one verb per phrase• Actors and resources must be LEL symbols• The objective must be concrete and precise• The context must have at least one item( place, time, pre-condition)• Resources must list all the resources used in the episodes, except for

those that will be used in sub-scenario• Actors must list all involved in the episodes execept for those used in

sub-scenarios• Each episode verb should be punctual • Episodes must happen within the limits/constraints imposed by the

context• Avoid using verbs such as “could”, “control”, “must”

“Tips”

Page 57: 1 Modelling III. 2 Objects Object – direct relationship with the real world Object –memory -> data -> Attributes –processes -> Operations -> Messages.

57

Requirement Sentences

• Derivate from scenarios

• Classify by type

• Number them (organization)