42
www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE) Multimedia Communications Research Laboratory (MCRLab) Distributed Collaborative Virtual Environments (DISCOVER) abed @ mcrlab.uottawa.ca http://www.mcrlab.uottawa.ca/

Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

Embed Size (px)

Citation preview

Page 1: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

1(c) elsaddik

CSI 1102

Abdulmotaleb El Saddik

University of Ottawa

School of Information Technology and Engineering (SITE)

Multimedia Communications Research Laboratory (MCRLab)

Distributed Collaborative Virtual Environments (DISCOVER)

abed @ mcrlab.uottawa.ca

http://www.mcrlab.uottawa.ca/

Page 2: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

Chapter 10: Software Engineering

Presentation slides for

Introduction to Software Design

Page 3: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

3(c) elsaddik

Software Engineering

The quality of the software is a direct result of the process we follow to create it

Chapter 10 focuses on:software development modelsthe software life cycle and its implicationslinear vs. iterative development approachesgoals and techniques of testingan evolutionary approach to object-oriented

developmenta nontrivial evolutionary development example

Page 4: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

4(c) elsaddik

The Software Life Cycle

The overall life cycle of a program go through 3 fundamentals stages

A version of the software that is made available to user is called a release

UseDevelopment

(4 steps)

Maintenance

Release

ReleaseBugs report

Concept

End of useful life

Page 5: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

5(c) elsaddik

Maintenance

Maintenance tasks include any modifications to an existing program; it includes enhancements and defect removal (Bugs fixes)

The characteristics of a program that make it easy to develop also make it easy to maintain

Maintenance efforts tend to far outweigh the development effort in today’s software

Page 6: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

6(c) elsaddik

Development vs. Maintenance

Use andMaintenance

Development

Page 7: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

7(c) elsaddik

Development and Maintenance Effort

Small increases in effort at the development stage greatly reduce maintenance tasks

The goal is to minimize the overall effort required to create and to maintain the program

Development Maintenance

Development Maintenance

Page 8: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

8(c) elsaddik

Development and Maintenance Effort

Often the maintainers of a program are not the program’s original developers

Maintainers must be able to understand a program they didn’t design

The ability to read and understand a program depends onhow clearly the requirements are establishedhow well the program is designedhow well the program is implementedhow well the program is documented

Page 9: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

9(c) elsaddik

Software Development Models

A software development model is an organized approach to creating quality software

Requirements, Design, Coding (implementation) and testing (Remember Chapter 3)

Too many programmers follow a build-and-fix approach:They write a program and modify it until it is functional,

without regard to system designErrors are addressed unsystematically if and as they

are discoveredIt is not really a development model at all

Page 10: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

10(c) elsaddik

The Build-and-Fix Approach

Writeprogram

Modifyprogram

Page 11: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

11(c) elsaddik

The Waterfall Model

The waterfall model was developed in the early 1970s

Activities that must be specifically addressed during development include:Establishing clear and unambiguous requirementsCreating a clean design from the requirementsImplementing the designTesting the implementation

Originally it was proposed as a linear model, without backtracking:One stage followed directly the next

Page 12: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

12(c) elsaddik

The Waterfall Model

Establish requirements

Create design

Implement code

Test system

It is a nice goal, but it is generally unrealistic

Page 13: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

13(c) elsaddik

Iterative Development

Iterative development allows the developer to cycle through the different development stages

It is essentially the waterfall model with backtracking

It should be used as a technique available to the developer to deal with unexpected problems that may arise in later stages of development

However backtracking should not be used irresponsibly

Page 14: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

14(c) elsaddik

An Iterative Development Process

Establishrequirements

Createdesign

Implementcode

Testsystem

Page 15: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

15(c) elsaddik

Testing

The results of each stage should be evaluated carefully prior to going on to the next stage Running a completed program with various inputs to

discover problemsTesting is also any action to asses the quality of the

software

Before moving on to the design, for example, the requirements should be evaluated to ensure completeness, consistency, and clarity

A design evaluation should ensure that each requirement was addressed adequately

Page 16: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

16(c) elsaddik

Testing Techniques

A design or an implementation may be evaluated during a walkthrough

The goal of a walkthrough is to identify problems, not to solve them

Presenting our design or code to someone else causes us to think more carefully about it

Participants discuss of merits and problems, and create a list of issues that must be addressed

Page 17: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

17(c) elsaddik

Testing Techniques

Generally, the goal of testing is to find errors

Often it is called defect testing

A good test uncovers problems in a program

A test case includesa set of inputsuser actions or other initial conditionsexpected output

Document it to reproduce errors if they occure

It is not feasible to test every possible case

Page 18: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

18(c) elsaddik

Black-Box Testing

Black-box testing maps a set of specific inputs to a set of expected outputsA test case is successful if the input produces the

expected outputA class can undergo black-box testing if we focus

on the system interfaces (public methods)

An equivalence category is a collection of input setsTwo input sets belong to the same equivalence

category if there is reason to believe that if one works, it will work for the other

Therefore testing one input set essentially tests the entire categoryDo not forget to test the test boundary

Page 19: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

19(c) elsaddik

White-Box Testing

White-box testing also is referred to as glass-box testing

It focuses on the internal logic such as the implementation of a method

Statement coverage guarantees that all statements in a method are executed

Condition coverage guarantees that all paths through a method are executed

Example:In a if-statement we have to test both paths:

The true path statement, andThe false path statement

Page 20: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

20(c) elsaddik

Prototypes: A way to sell Ideas

A prototype is a program created to explore a particular conceptA prototype could also be presented through a set

of diagrams Prototyping is more useful, time-effective, and cost-

effective than merely acting on an assumption that later may backfire

Usually a prototype is created to communicate to the client:a particular taskthe feasibility of a requirementa user interface

It is a way of validating requirements

Page 21: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

21(c) elsaddik

Presenting User Interface SW-Prototype

Computer Telephone Last Name: First Name: Phone:

Place Call Help

Return

Help Screen You can enter either the person's name or their number. Then hit the place button to call them

Computer Telephone Last Name: First Name: Phone:

Place Call Help

Computer Telephone

Last Name: Greenberg First Name: Phone:

Place Call Help

Computer Telephone

Last Name: Greenberg First Name: Phone:

Place Call Help

Dialling....

Cancel

Computer Telephone

Last Name: Greenberg First Name: Phone:

Place Call Help

Connected

Hang up

Computer Telephone Last Name: First Name: Phone:

Place Call Help

Help-

Type name and place call

Page 22: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

22(c) elsaddik

A “quick and dirty” prototype to test an idea or a concept is called a throw-away prototype

Throw-away prototypes should not be incorporated into final systems

Because it is designed more carefully, an evolutionary prototype can be incorporated into the final system

Evolutionary prototypes provide a double benefit, but at a higher cost

Throw-away vs. Evolutionary Prototypes

Page 23: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

23(c) elsaddik

Evolutionary Development

Evolutionary development divides the design process intoarchitectural design – High level design

General structure and responsibilitiesprimary classes and interaction

detailed design specific classes, methods, and algorithms

This allows us to create refinement cyclesEach refinement cycle focuses on one aspect of the

systemAs each refinement cycle is addressed, the system

evolves

Page 24: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

24(c) elsaddik

An Evolutionary Development Model

Establish requirements

Architectural design

Establish refinement

scope

Unit and integration

test

Implementation

System test

Identify classes & objects

Identify relationships

Detailed design

Page 25: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

25(c) elsaddik

Refinement Cycle: #1 Establish the Scope

First, we establish the refinement scope to define the specific nature of the next refinement

For example:Create part of the user interface for the programTest the feasibility of a particular requirementDevelop utility classes for general program support

Object-oriented programming is well suited to this approach

Choosing the most appropriate next refinement is important and requires experience

Page 26: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

26(c) elsaddik

Refinement Cycle: #2 Identify relevant classes/objects

Identify classes and objects that relate to the current refinementLook at the nouns in the requirements document

Candidates categories includephysical objects (books, balls, etc.)People (student, clerk, professor, etc.)Places (room, airport, etc.)Containers (bookcase, transaction list, etc.)Occurrences (sale, meeting, accident, etc.)Information stores (catalog, event log)

Categories may overlapConsider reusing existing classes

Is Student Class enough? What about Grad. & Under Grad?

Page 27: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

27(c) elsaddik

Refinement Cycle: #3 Identify relationships

Identify relationships among classesgeneral association (“uses”)aggregation (“has-a”)inheritance (“is-a”)

Associated objects use each other for the services they provide

Aggregation, also called composition, permits one object to become part of another objectCardinality describes the numeric relationship between

the objectsFor example, a car might have four wheels associated

with it

Page 28: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

28(c) elsaddik

Refinement Cycle: #3 (cont.) Inheritance

Inheritance, discussed in detail in Chapter 7, may lead to the creation of a new “parent” abstract class whose sole purpose is to gather common data and common methods in one

place

Use UML class diagrams to show the relationships

Page 29: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

29(c) elsaddik

Refinement Cycle: #3 (cont.)

StudentBody

+ main (args : String[]) : void

+ toString() : String

1 2Student

- firstName : String- lastName : String- homeAddress : Address- schoolAddress : Address

+ toString() : String

- streetAddress : String- city : String- state : String- zipCode : long

Address

Person

# age : int

+ toString () : String

Aggregation

Association Inheritance

Page 30: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

30(c) elsaddik

Refinement Cycle: #4-6Detailed design, implement and test

Finally, a refinement cycle includes detailed design, implementation, and testingAll the members of each class need to be definedEach class must be implemented (coded)Stubs sometimes are created to permit the refinement

code to be tested

A unit test focuses on one particular component, such as a method or a class

An integration test focuses on the interaction between components

Page 31: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

31(c) elsaddik

Specification of code

Specification of design details

Invariant: collection of facts which are truePrecondition/Postcondition

Preconditions: Conditions which are required for code to execute correctly

Postconditions: Correct changes which result after code has been executed

Page 32: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

32(c) elsaddik

Specification of code:An Example (AlarmClock class)

Invariant

An Alarmclock object

Keeps track of a single alarm time in terms of time and minutes

Cannot distinguish between AM and PM times

Has attribute values restricted to the following ranges:1 <= hour <= 12 and 0 <= minutes <= 59

Update Methods

public void advanceOneHour()

precondition

hour < 12

modifies

hour

postcondition

The value of hour is one unit larger than before

Page 33: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

33(c) elsaddik

Specification of code: An Example (AlarmClock class)

Update Methods (cont…)

public void advanceTenMinutes()

precondition

minute < 50

modifies

minute

postcondition

The value of minute is 10 units higher than before

We can use formal logic to express the invariant, pre/post conditions

We can then use formal logic to prove that a piece of code is “True”.

Source: “The object of Java”, David D Riley, Addison-Wesley, 2002

Page 34: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

34(c) elsaddik

Obtaining the requirements: The PaintBox project

TASK (High level): Create a program which allows the user to draw

various shapes and sizes on the screen

How will we go about accomplishing this?

Page 35: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

35(c) elsaddik

The PaintBox project: Requirements

Create a mouse driven GUIAllow user to draw lines, circles, ovals, rectangles and

squaresAllow user to change drawing colorAllow user to fill a shape, except a line, with a color.Allow user to being new drawingAllow user to create polylines

Page 36: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

36(c) elsaddik

The PaintBox Project:Initial Refinement steps

create the basic user interfaceallow the user to draw and fill shapes and to change

colorallow the user to select, to move, and to modify

shapesallow the user to cut, copy, and paste shapesallow the user to save and to reload drawingsallow the user to begin a new drawing at any time

Page 37: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

37(c) elsaddik

The PaintBox Project: The Basic User Interface

File Edit

Select OvalLine Rect Color

Drawing Area

Page 38: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

38(c) elsaddik

The PaintBox Project

Discussions with the client lead to additional requirements which are integrated into the requirements documentNext the architectural design is preparedRefinement steps are determined#1: the basic user interface#2: drawing basic shapes using different stroke colors#3: cutting, copying, and pasting shapes#4: selecting, moving, and filling shapes#5: modifying the dimensions of shapes#6: saving and reloading drawings#7: final touches such as the splash screen

Page 39: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

39(c) elsaddik

Remaining PaintBox Refinements

The full implementation can be downloaded for the Book’s Website

See 10.4 of the text book

Page 40: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

40(c) elsaddik

Obtaining user requirements: The “toughest part”

“Knowledge acquisition bottleneck”: Difficulty to extract information from humans

Different personality types:Levels of detail, concepts, thinking holistic, etc.Myers Briggs (16 types), amongst others

Processing data and information: concrete versus abstract

Decision making: logical and objective versus value related and subjective

Introvert versus extravert: stimuli from outside or inside

Judgment: random versus “open-ended”See WWW for tests and for sceptics!!!!

Page 41: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

41(c) elsaddik

Summary: Chapter 10

Chapter 10 has focused on:software development modelsthe software life cycle and its implicationslinear vs. iterative development approachesgoals and techniques of testingan evolutionary approach to object-oriented

development

Page 42: Www.site.uottawa.ca/~elsaddik 1 (c) elsaddik CSI 1102 Abdulmotaleb El Saddik University of Ottawa School of Information Technology and Engineering (SITE)

ww

w.s

ite.

uo

ttaw

a.ca

/~el

sad

dik

42(c) elsaddik

Thank You!