software development problem analysis and specification design implementation (coding) testing,...
TRANSCRIPT
![Page 1: Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance](https://reader036.vdocuments.site/reader036/viewer/2022062518/5697bf7c1a28abf838c841fb/html5/thumbnails/1.jpg)
Software Development
• Problem Analysis and Specification
• Design
• Implementation (Coding)
• Testing, Execution and Debugging
• Maintenance
![Page 2: Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance](https://reader036.vdocuments.site/reader036/viewer/2022062518/5697bf7c1a28abf838c841fb/html5/thumbnails/2.jpg)
Problem Analysis and SpecificationComputer Science programming assignment -
specific statement of problem
quantitative description
clearly defined requirements for needed:
input, output, calculations, test data
Computer Science programming assignment -
specific statement of problem
quantitative description
clearly defined requirements for needed:
input, output, calculations, test data
CPSC 185 - Assignment 4 Due : Wednesday, March 11
The sum-of-the-years digits method of calculating depreciation is illustrated below.
$15,000 is to be depreciated over five years.First calculate the “sum-of-the-years digits,” 1 + 2 + 3 + 4 + 5 = 15.Then depreciate 5/15 of $15,000 ($5,000) over the first year,4/15 of $15,000 ($4,000) over the second year,3/15 ($3,000) the third year, and so on.
Write a program that reads the amount to be depreciated and the number of years overwhich it is to be depreciated. Then for each year from 1 through the specified number ofyears, print the year number and the amount of depreciation for that year under appropriateheadings. Execute the program with the following data: $15,000 for 3 years; $7,000 for 10years; $500 for 20 years; $100 for 1year.
![Page 3: Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance](https://reader036.vdocuments.site/reader036/viewer/2022062518/5697bf7c1a28abf838c841fb/html5/thumbnails/3.jpg)
Problem Analysis and Specification
To: Bob Byte, Director of Computer Center
From: Chuck Cash, V.P. of Scholarshipsand Financial Aid
Date: Wednesday, March 11
Because of new government regula-tions,we must keep more accurate records of all studentscurrently receiv-ing financial aid and submit regular reports to FFAO (Federal Financial AidOffice). Could we get the computer to do this for us?
CC
“Real World” request -
general statement of problem
qualitative (“more accurate”) not quantitative
precision missing for
input, output, processes
“Real World” request -
general statement of problem
qualitative (“more accurate”) not quantitative
precision missing for
input, output, processes
![Page 4: Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance](https://reader036.vdocuments.site/reader036/viewer/2022062518/5697bf7c1a28abf838c841fb/html5/thumbnails/4.jpg)
Statement of specifications
the formal statement of the problem’s requirements
the major reference document
a benchmark used to evaluate the final system
![Page 5: Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance](https://reader036.vdocuments.site/reader036/viewer/2022062518/5697bf7c1a28abf838c841fb/html5/thumbnails/5.jpg)
Design• CS courses
– small systems • few hundred lines of
code
• simple, straightforward
• self-contained
• “Real” world– large systems
• thousands of lines of code
• complex
• many components
![Page 6: Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance](https://reader036.vdocuments.site/reader036/viewer/2022062518/5697bf7c1a28abf838c841fb/html5/thumbnails/6.jpg)
Object-centered design
• 1. Identify the objects in the problem's specification.
• 2. Identify the operations needed to solve the problem.
• 3. Arrange the operations in a sequence of steps, called an algorithm, which, when applied to the objects, will solve the problem.
![Page 7: Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance](https://reader036.vdocuments.site/reader036/viewer/2022062518/5697bf7c1a28abf838c841fb/html5/thumbnails/7.jpg)
Algorithm
• May be written in pseudo-code
• Characteristics of steps (instructions), see pg 9:– Definite and unambiguous
– Simple
– Finite
• Difference between correctness and efficiency, see pp 7-8– O(n) — grows linearly with size (n) of the input
– O(1) — is constant , i.e. independent of size of input
![Page 8: Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance](https://reader036.vdocuments.site/reader036/viewer/2022062518/5697bf7c1a28abf838c841fb/html5/thumbnails/8.jpg)
Algorithm (Structured Version)
/* Algorithm to read and count several triples of distinct numbers and print the largest number in each triple. */
1. Initialize count to 0.
2. Read the first triple of numbers x, y, z.3. While x is not the end-of-data-flag do the following:
a. Increment count by 1.
b. If x > y and x > z then display x.
Else if y > x and y > z then display y
Else display z.
c. Read the next triple x, y, z.
4. Display count.
![Page 9: Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance](https://reader036.vdocuments.site/reader036/viewer/2022062518/5697bf7c1a28abf838c841fb/html5/thumbnails/9.jpg)
Implementation
• Select language of implementation
• Encode the design
• Verify Integration– combining program units into a complete software system.
• Insure Quality– programs must be correct, readable, and understandable
– well-structured, documented, stylistic (see guidelines on pp. 15-18)
![Page 10: Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance](https://reader036.vdocuments.site/reader036/viewer/2022062518/5697bf7c1a28abf838c841fb/html5/thumbnails/10.jpg)
Testing, Execution, and Debugging
– Validation: "Are we building the right product?" • check that documents, program modules, etc. match
the customer's requirements.
– Verification: : "Are we building the product right?" • check that products are correct, complete, consistent
with each other and with those of the preceding phases.
![Page 11: Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance](https://reader036.vdocuments.site/reader036/viewer/2022062518/5697bf7c1a28abf838c841fb/html5/thumbnails/11.jpg)
Errors may occur in any of the phases
– Specifications don't accurately reflect given information or the user's needs/requests
– Logic errors in algorithms – Incorrect coding or integration– Failure to handle boundary data or test values
![Page 12: Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance](https://reader036.vdocuments.site/reader036/viewer/2022062518/5697bf7c1a28abf838c841fb/html5/thumbnails/12.jpg)
Different kinds of tests required
– Unit tests: • Each individual program unit works?
– Program components tested in isolation
– Integration tests: • Units combined correctly?
– Component interface and information flow tested
– System tests: • Overall system works correctly?
![Page 13: Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance](https://reader036.vdocuments.site/reader036/viewer/2022062518/5697bf7c1a28abf838c841fb/html5/thumbnails/13.jpg)
The "V" Life Cycle Model
![Page 14: Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance](https://reader036.vdocuments.site/reader036/viewer/2022062518/5697bf7c1a28abf838c841fb/html5/thumbnails/14.jpg)
Unit testing
– probably the most rigorous and time-intenstive– surely the most fundamental and important– kinds of errors tested
• — syntax
• — linking
• — run-time
• — logical
![Page 15: Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance](https://reader036.vdocuments.site/reader036/viewer/2022062518/5697bf7c1a28abf838c841fb/html5/thumbnails/15.jpg)
Black box or functional test
• Outputs produced for various inputs are checked for correctness without considering the structure of the module itself. (
• Program unit is viewed as a black box that accepts inputs and produces outputs, but the inner workings of the box are not visible.
![Page 16: Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance](https://reader036.vdocuments.site/reader036/viewer/2022062518/5697bf7c1a28abf838c841fb/html5/thumbnails/16.jpg)
White box or structural test
• Performance is tested by examining code’s internal structure.
• Test data is carefully selected so that specific parts of the program unit are exercised.
![Page 17: Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance](https://reader036.vdocuments.site/reader036/viewer/2022062518/5697bf7c1a28abf838c841fb/html5/thumbnails/17.jpg)
Example: Binary search (pp. 19-23)/* INCORRECT IMPLEMENTATION OF FUNCTION BinarySearch() performs a binary search of array a for item.
Receive: item, array a of n items, sorted in ascending order Pass back: found (true if search successful) and
mid ( the position of item in a)-------------------------------------------------------*/
void BinarySearch(NumberArray a, int n, ElementType item, bool & found, int & mid)
{ int first = 0, // first and last positions in sublist last = n - 1; // currently being searched *) found = false; while (first <= last && !found) { mid = (first + last ) / 2; if item < a[mid] last = mid; else if item > a[mid] first = mid; else found = true } }
![Page 18: Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance](https://reader036.vdocuments.site/reader036/viewer/2022062518/5697bf7c1a28abf838c841fb/html5/thumbnails/18.jpg)
Black box test Use n = 7 and sample array a of integers
a[0]=45 a[1]=64 a[2]=68 a[3]=77 45 a[4]=84 a[5]=90 a[6]=96
Test with item = 77 returns found = true, mid = 3
Test with item = 90 returns found = true, mid = 5
Test with item = 64 returns found = true, mid = 1
Test with item = 76 returns found = false
Hey, it seems to work ok! Are we done yet?
![Page 19: Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance](https://reader036.vdocuments.site/reader036/viewer/2022062518/5697bf7c1a28abf838c841fb/html5/thumbnails/19.jpg)
Boundary TestingMust consider special cases:
Non-member values tested above,Boundary values (at bounds of data structures) not.
item = 45: found = true and mid = 0 OK
item = 96: doesn’t terminate; must “break” program. ERROR!!
![Page 20: Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance](https://reader036.vdocuments.site/reader036/viewer/2022062518/5697bf7c1a28abf838c841fb/html5/thumbnails/20.jpg)
Techniques to locate errorDebug statements (p. 21)
cerr << "DEBUG: At top of while loop in BinarySearch()\n" << "first = " << first << ", last = " << last << ", mid = " << mid << endl;
Output:
DEBUG: At top of while loop in BinarySearch()first = 0, last = 6, mid = 3DEBUG: At top of while loop in BinarySearch()first = 3, last = 6, mid = 4DEBUG: At top of while loop in BinarySearch()first = 4, last = 6, mid = 5DEBUG: At top of while loop in BinarySearch()first = 5, last = 6, mid = 5DEBUG: At top of while loop in BinarySearch()first = 5, last = 6, mid = 5DEBUG: At top of while loop in BinarySearch()first = 5, last = 6, mid = 5
![Page 21: Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance](https://reader036.vdocuments.site/reader036/viewer/2022062518/5697bf7c1a28abf838c841fb/html5/thumbnails/21.jpg)
White-box test
Use knowledge of control flow of program to devise test data.
Exercise the different paths of execution to find errors
e.g., Use item < 45 to test a path in whichthe first condition item < a[mid] is always trueso first alternative last = mid; is always selected.OK!
Use item > 96 to test a path in which the second condition item > a[mid] is always true so second alternative first = mid; is always selected. ERROR! Infinite loop
![Page 22: Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance](https://reader036.vdocuments.site/reader036/viewer/2022062518/5697bf7c1a28abf838c841fb/html5/thumbnails/22.jpg)
Maintenance– Large % of computer center budgets– Large % of programmer's time– Largest % of software development cost
• Why? – Includes modifications and enhancements– Poor structure, poor documentation, poor style
• less likely to catch bugs before release• make fixing of bugs difficult and time-consuming• impede implementation of enhancements