Top Banner
S D 1 Object Oriented Analysis & Design
29
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Analysis

SD

1

Object OrientedAnalysis & Design

Page 2: Analysis

SD

2

Contents

• Why OOA/OOD

• The Software life cycle

• Detailed example> following an example from “Patterns in Java” by Mark Grand

Page 3: Analysis

SD

3

Why OOA/OOD

• Claims to model the same way we think> we think of something - a concept - and then wonder

“what can it do ?”

• Easy transition from analysis/design to implementation...

> ...using an object oriented language

• Claims to reduce risk

• Trendy> just look at want adds

Page 4: Analysis

SD

4

OOA/OOD Process

• Planing> Business case

> Budget

• Detailed Planing> Requirement specification

> Essential use-cases

> Prototype

• Build> Phase 1

° OOA• Low level essential use cases

• Conceptual Model

• Sequence diagrams

Page 5: Analysis

SD

5

OOA/OOD Process (cont’)

• Build> Phase 2

° UI design

° DB design

° OOD• Class diagrams

• Collaboration diagrams

• State diagrams

> Phase 3

° Usability testing

° Coding

° Physical DB design

> Phase 4

° Testing

Page 6: Analysis

SD

6

OOA/OOD Process (cont’)

• Build> Orthogonal activities

° Write documentation and Help

• Deployment

Page 7: Analysis

SD

7

Case study - Henry’s Food Market

Henry’s Food Market operates five retail stores. To support these stores, it alsooperates a warehouse and a commercial bakery that produces the baked goods thatthe stores sell. Most of its employees are paid by the hour. Employee hours are trackedby a time-clock system. When employees start work, go on breaks, return from breaks,or leave work they are supposed to slide their employee badges through a timekeepingclock that records their hours.Henry’s Food Market wants to expand, increasing the number of its stores from 5 to 21over the next 2 years at a rate of 2 stores every 3 months. One of the challenges thatfaces the company is that if it continues to use its existing timekeeping system, it willhave to hire more people to handle the administrative side of timekeeping. Currently,each location requires a person working half-time as a timekeeper to administer itstimekeeping system. The activities the timekeeper is required to perform are as follows:•The timekeeper prints reports for supervisors that show the number of hours that each employee worked the previous day. This allows supervisors the ability to verify that their subordinates worked the stated number of hours. Some common errors that are uncovered by the supervisors who review these reports are:

• Employees don’t clock out when they go on break or leave work.• Coworkers clock in employees who are late to work.• Employees clock in before start of their shift.

• The timekeeper enters corrections into the timekeeping system.• The timekeeper prepares weekly reports that show the number of hours every employee in a location worked and sends those reports to the payroll department. … (other cost-related topics - do Project Planing & Management - IE Department)

Page 8: Analysis

SD

8

Define Requirement Specification

• Required Functions> the things the system must do

° record the time an employee starts work

• Required Attributes> other characteristics of the system

° use of time-keeping terminals not require more than an eight-grade education

• Assumptions> list of things that are assumed to be true

° minimum education requirement for employees

° the company won’t become unionized

• Risks> technical uncertainties.

° availability of terminals

> non-technical concerns.

° change in labor laws

• Dependencies° the project relies on the existence of a WAN - wide area network

Page 9: Analysis

SD

9

Requirement MatrixID DescriptionR1 The system must document the hours that employees start work, go on

break, return from break, and leave work.R1.1 In order to work with the timekeeping terminal, employees are required to

identify themselves by sliding their employee badges through a badgereader on the timekeeping terminal.

R1.2 After an employee is identified to a timekeeping terminal, the employeecan press a button to indicate if he or she is starting a work shift, going ona break, returning from break, or ending a work shift. The timekeepingsystem keeps permanent record for each such event in a form that it canlater incorporate into a report documenting the employee’s hours.

R2 Supervisors must be able to review the hours of subordinates at atimekeeping terminal without any need to get a hard copy.

R2.1 The timekeeping terminal presents options that allow supervisors toreview and modify an employee’s recorded hours.

R2.1.1 All revisions made to an employee’s timekeeping record leave an audittrail that retains the original records and identifies the person who madeeach revision.

R2.2 To ensure the simplest possible user interface for non-supervisors,non-supervisors don’t see any options related to supervisory functionswhen they use a timekeeping terminal.

R2.3 Supervisors can modify the timekeeping records only of their ownsubordinates.

R3 At the end of each day period, the timekeeping system must automaticallytransmit employee hours to the payroll system.

As we develop some use cases, you can expectto discover additional required functions

Page 10: Analysis

SD

10

Requirements Matrix

• Organize the requirements onto categories (linnaean classification)

> allows trace and cross-reference of requirements

• Enable us to justify every capability we include/drop from our product

> again - cross reference

• Serves as a basis for System testing> every item on the requirement matrix should be tested

Page 11: Analysis

SD

11

High Level Essential Use Cases

Use case: Employee uses Timekeeping Terminal, version 1

Actor: Employee

Purpose: Inform timekeeping system of an employee’s coming andgoing.

Synopsis: An employee is about to start a work shift, go on break,return from break, or end a work shift. The employeeidentifies him- or herself to the timekeeping system and letsit know which of those four things he or she is about to do.

Type: Primary and essential

Cross-reference: R1,R1.1,R1.2,R1.3,R2.2

A common use case:

Page 12: Analysis

SD

12

High Level Essential Use Cases

Employee System

1. Employee slides his or her badgethrough a timekeeping terminal’sbadge reader

2. The timekeeping terminal reads the employee IDfrom the badge and verifies that it’s a legitimateemployee ID. The timekeeping terminal thenprompts the employee to tell it if he or she isstarting a work shift, going on a break, returningfrom a break, or ending a work shift.

3. The employee indicates to thetimekeeping terminal whether he orshe is starting a work shift, going onbreak, returning from break, orending a work shift.

4. The timekeeping terminal makes a permanentrecord of the employee’s indication. It thenacknowledges the employee with a display of thecurrent time, indicating that it is ready for use by thenext employee.

Course of Events:

Tracking the course of even we can see another requirementwe didn’t document yet:R1.3 The times displayed and recorded by different timekeepingterminals must be within 5 seconds of each other

Page 13: Analysis

SD

13

Prototypes

• What> A look and feel of the real thing

° assists in early discovery of conceptual errors

• How> Rapid Prototyping tools

° Visual Basic

° SWIG

Page 14: Analysis

SD

14

Object Oriented Analysis

• Our purpose: construct a conceptual model of the problem.

> Identify the entities that are involved.

> identify the relationships between these entities.

• Heuristics> Look for the nouns in the problem description.

> Use CRC cards.

Page 15: Analysis

SD

15

Case study - Henry’s Food Market

Henry’s Food Market operates five retail stores. To support these stores, it alsooperates a warehouse and a commercial bakery that produces the baked goods thatthe stores sell. Most of its employees are paid by the hour. Employee hours are trackedby a time-clock system. When employees start work, go on breaks, return from breaks,or leave work they are supposed to slide their employee badges through a timekeepingclock that records their hours.Henry’s Food Market wants to expand, increasing the number of its stores from 5 to 21over the next 2 years at a rate of 2 stores every 3 months. One of the challenges thatfaces the company is that if it continues to use its existing timekeeping system, it willhave to hire more people to handle the administrative side of timekeeping. Currently,each location requires a person working half-time as a timekeeper to administer itstimekeeping system. The activities the timekeeper is required to perform are as follows:•The timekeeper prints reports for supervisors that show the number of hours that each employee worked the previous day. This allows supervisors the ability to verify that their subordinates worked the stated number of hours. Some common errors that are uncovered by the supervisors who review these reports are:

• Employees don’t clock out when they go on break or leave work.• Coworkers clock in employees who are late to work.• Employees clock in before start of their shift.

• The timekeeper enters corrections into the timekeeping system.• The timekeeper prepares weekly reports that show the number of hours every employee in a location worked and sends those reports to the payroll department. … (other cost-related topics - do Project Planing & Management - IE Department)

Page 16: Analysis

SD

16

A Conceptual Model

PayPeriodTimekeeper

Employee

Break

Supervisor

TimekeepingEvent

Shift

EmployeeBadge

TimekeepingLog

TimekeepingSystemEmployeeID

TimekeepingReport

PayrollSystem

Page 17: Analysis

SD

17

A Conceptual Model - with associations

PayPeriodTimekeeper

Employee

Break

Supervisor

TimekeepingEvent

Shift

EmployeeBadge

TimekeepingLog

TimekeepingSystemEmployeeID

TimekeepingReport

PayrollSystem

Is-A

Uses

Modifies

Creates

Is-part-of

Is-A

Owns

Modifies Belongs-to Uses

Is-part-of

Is-part-ofContains

possession

owner

user

usee

creator createe

part wholepart

whole

part

whole

user

usee

1

11

0..*

0..*

0..*

1

1

1

0..*0..*

1

11

0..12

Page 18: Analysis

SD

18

TimekeepingEvent

A Conceptual Model - with attributes

PayPeriodTimekeeper

Employee

Break

SupervisorShift

EmployeeBadge

TimekeepingLog

TimekeepingSystem

employeeID

TimekeepingReport

PayrollSystem

Is-A

Uses

Modifies

Creates

Is-part-of

Is-A

Owns

Modifies Belongs-to Uses

Is-part-of

Is-part-ofContains

possession

owner

user

usee

creator

createe

part whole

part

whole

part

whole

user

usee

1

1

1

0..*

0..*

0..*

1

1

1

0..*0..*

1

11

0..12when:time

start:timeend:time

Page 19: Analysis

SD

19

CRC Cards

• Class-Responsibility-Collaboration cards

• 3x5 or 4x6 cards

Class name (* if abstract)

• List of responsibilities• ...•

• List of collaborating classes• ...•

Page 20: Analysis

SD

20

Object Oriented Design

• Construct Class diagrams

• Define All use cases

• Create interaction diagrams based on use cases> Collaboration Diagrams

> Sequence Diagrams

• Define system behavior as a state machine> State Diagrams

Page 21: Analysis

SD

21

Class Diagrams

• Incremental process - add classes on the fly.

• Start modeling program domain classes and not just problem domain classes e.g.

> User Interface

> Transaction Log

> Containers

• The conceptual model is an excellent start.

Page 22: Analysis

SD

22

TimekeepingEvent

Class Diagram - Ver. 1

PayPeriod

Timekeeper

EmployeeBreak

SupervisorShift

EmployeeBadge

TimekeepingLog

TimekeepingSystem

getEmployeeID:String

TimekeepingReport

PayrollSystem

getTime():Date

getStart():DategetEnd():Date

• Add acessor methods for all attributes

Page 23: Analysis

SD

23

TimekeepingEvent

Class Diagram - Ver. 2

PayPeriodTimekeeper

Employee

Break

Supervisor

Shift

EmployeeBadge

TimekeepingLog

TimekeepingSystem

getEmployeeID:String

TimekeepingReport

PayrollSystem

getTime():Date

getStart():DategetEnd():Date

• Consider “Is-A” relationships

Why would we prefer delegation rather than inheritance for theseclasses ?

Page 24: Analysis

SD

24

Detailed Use Cases

Use case: Employee uses Timekeeping Terminal To Track Hours,version 1

Actor: Employee

Purpose: Inform timekeeping system of an employee’s coming andgoing.

Synopsis: An employee is about to start a work shift, go on break,return from break, or end a work shift. The employeeidentifies him- or herself to the timekeeping system and letsit know which of those four things he or she is about to do.

Type: Primary and real

Cross-reference: R1,R1.1,R1.2,R1.3,R2.2, Essential use case “EmployeeUses Timekeeping Terminal”

A common use case:

Page 25: Analysis

SD

25

High Level Essential Use Cases

Employee System1. Employee slides his or her badgethrough a timekeeping terminal’s badgereader

2. The timekeeping terminal replaces it’s display of thecurrent time – indicating it’s availability for use – with adisplay that tells the employee that it’s looking up theemployee ID detected by the badge reader.After the timekeeping terminal finds the employee’sinformation, it verifies that the employee is allowed to usethis particular timekeeping terminal. The timekeepingterminal then prompts the employee to tell if he or she isstarting a work shift, going on break, returning from breakor ending a work shift

3. The employee indicates to thetimekeeping terminal whether he or sheis starting a work shift, going on break,returning from break, or ending a workshift.

4. The timekeeping terminal makes a permanent record ofthe employee’s indication. It then acknowledges thecompletion of the timekeeping transaction with a display ofthe current time, indicating that it is ready for use by thenext employee.

Course of Events:

This use case involves classes that are not in the previous class diagram - atimekeeping terminal’s user-interface, which in turn be further broken down toother classes.

Page 26: Analysis

SD

26

Collaboration Diagram

:UserInterface

:TimekeepingControler

:TimekeepingEvent:Database

1: doTransaction(id)

1.2: eventType := getEventType()

1.1: emp := lookupEmployee()1.4: storeEvent(start)

1.3:start = createEvent(eventType)

• Start shift collaboration diagram

id:EmployeeID emp:Employee start:StartShiftEvent

Page 27: Analysis

SD

27

Class Diagram - Ver. 3

UserInterface

getEventType():int

TimekeepingController

doTransaction(employeeID:String)

Database

lookupEmployee(employeeID:String):EmployeestoreEvent(event:TimekeepingEvent)

TimekeepingEvent

START_SHIFT:int = 0 {frozen}START_BREAK:int = 1 {frozen}END_SHIFT:int = 2 {frozen}END_BREAK:int = 3 {frozen}

getEmployee():EmployeegetTime():DatecreateEvent(eventType:int):TimekeepingEvent

Employee

getEmployeeID():String

TimekeeperSupervisor

PayPeriod

getStart():DategetEnd():Date

Break Shift

TimekeepingLog

TimekeepingReport

PayrollSystem

Uses-symbolic-names-defined-by

Uses

Request-event-object-creation

Stores-and-fetches-data-for

Plays-role Plays-role

role role

player

player

1

11

1

1

1

1

1

1

0

1

0requestor

creator

Page 28: Analysis

SD

28

State Diagrams

• Based on David Harel’s Statecharts.

• A state machine describing some process.

• State Diagrams are comprised of:> states

° modeling a certain state an object might be in.

> transitions

° describing how object state may change

> actions

° which are performed in a state

> triggers

° which activate state transitions (may be guarded by a predicate)

Page 29: Analysis

SD

29

State Diagrams (cont’)

StartPayPeriod

StartPayPeriod

Enter / incompleteShift=false startTime=event.getTime()

StartBreak

Enter / breakTime=event.getTime()

EndBreak

Enter / unpaidHours += event.getTime()- breakTime regularHours -= eventTime()-breakTime

EndShift

Enter / regularHours += event.getTime()-startTime if (regularHours>40) { overtimeHours += regularHours - 40; regularHours = 40; } regularPay = regularHours * payRate; overtimePay = overtimeHours * payRate * 1.5; createShift();

regularHours=0;overtimeHours=0;unpaidHours=0;regularPay=0;overtimePay=0; StartShift

StartBreak

EndBreak StartBreakEndShift StartShift

EndShift