CPSC 110 - Pascal Chapter 3, part 2

advertisement
Software Engineering
Chapter 3
CPSC 110 - Pascal
Brent M. Dingle
Texas A&M University
Software Engineering




Robustness of a program
Iterative Enhancement
Testing and Debugging – types of errors
Software Life Cycle
Robustness
 In general a robust program is a program that does
not fail due to unexpected or unlikely input.
 In general a robust program will consider all forms
and types of input – including input that is entered
incorrectly by the user.
 It will guarantee that any assumptions it had to
make about the input are indeed true.
 How this is accomplished is dependant on the
programmer, the problem and ‘other’ things.
Iterative Enhancement
 Iterative Enhancement is the process of first
designing a simple program and then adding
features and refinements as deemed necessary.
Testing and Debugging
 This is perhaps THE most important part of
programming.
 If a program is NOT tested how do you know it was
actually programmed correctly?
 Even the best algorithms must be explained to the
computer correctly.
Testing
 Testing a program means running it and trying to
find errors in it.
 It is best to use as many forms of testing as
possible.
 It is best to have as many people as possible test the
program – and the program’s writers are NOT very
good testers because they already know what the
program is supposed to do.
Debugging
 Debugging is the removing of errors (bugs) from a
program.
 There are several ‘types’ of errors you will find:



syntax errors
runtime errors
logical errors
Syntax Errors
 Syntax errors are violations of the syntax
(grammar) rules of the programming language.
 These are the ONLY type of errors that the compiler
will detect.
Runtime Errors
 Runtime errors occur when the program is running.
 Most runtime errors involve numeric calculations.
 For example:

Because a computer is finite you can increment a number too far –
this results in an overflow error.


In old video games you could ‘flip’ the score back to zero.
Other runtime errors are:



division by zero
taking the square root of a negative number
etc.
 Do NOT confuse these with logical errors !
 Some say runtime errors are caused by logical errors – but
it is more often a failure in robustness.
Logical Errors
 Logical errors are mistakes in the algorithm itself.
 This means that the program compiles AND runs, but
produces an incorrect result.
 You will NOT receive any error from the computer
concerning these types of errors.
 Often these errors involve using less than (<) when you
meant to use greater than(>) or something similar.
 But every now and then, they are caused by simply using an
incorrect algorithm entirely.
Software Life Cycle – in general
 There are several different descriptions of the
software life cycle found throughout computer
science.
 For this class we will use the one presented in the
book.
 If you would like to see others, do some research on
it. =)
Software Life Cycle – 6 Phases






Analysis and task specification.
Design of the software.
Implementation (coding).
Testing.
Maintenance and evolution of the system.
Obsolescence.
Analysis Phase
 During this phase, many questions are
answered in particular the question:
WHAT must the software do?
 Here it must be determined what the software
is expected to do by the person paying for the
development and by the expected users.
 Usually specifications are set in this phase –
or rather the software’s requirements.
Design Phase
 This phase answers the question:
HOW must the software do (whatever)?
and the (whatever) was determined in the
Analysis phase.
 In this phase algorithms will be selected or
created as needed.
 The (program and data) structure of the
software should also be determined here.
Implementation (coding) Phase
 Once the algorithms are determined, they will be
coded (programmed into the computer).
 Sometimes (often) this phase will lead back to the
design phase as unforeseen problems in the design
are encountered.
Testing Phase
 Testing is often broken down into small pieces so
that each part of a piece of software is tested at first.
 Once each small part is tested then larger parts are
tested and eventually the final product will be tested
(all this is theoretical of course =)
 Testing is sometimes incorporated into the Design
and/or the Implementation Phase and you will
bounce back and forth as debugging takes place.
Maintenance Phase
 This phase begins immediately after the
program is ‘released’ for use.
 Inevitably more bugs are found as time goes
on and more needs will arise, so the software
will need to be maintained – to fix previously
unknown bugs, to modify the code to meet
new needs, to fix new bugs introduced by the
maintenance process itself and so on.
Obsolescence Phase
 This phase is entered when a piece of software is seen to no
longer have any value.
 This does not always mean the software is removed
completely from use.
 It means that the maintenance phase will no longer occur
and that using an obsolete piece of software is ‘at your own
risk.’
 This phase often occurs when a company changes operating
systems or computer systems or when technology simply
advances beyond the software and better software is
available.
End Software Engineering
Download