Analysis is the first phase of the software development process.
Purpose: Understand the problem before you try to solve it. Be certain that customer requirements are entirely specified and understood by developer. Analyze the problem statement (or customer requirements) and write a document which specifies the behavior of the software to be built. This document is called a "software specification." It is a precise statement of exactly WHAT the software is to accomplish. (Often the specification is the legal contract binding the developer and the customer).
Method: Since the english language is notoriously imprecise and subject to misinterpretation, the analyst's job is to scrutinize the problem statement to uncover any possible ambiguities.
Read the problem statement and write down all questions that occur to you, any statements that are confusing, or subject to misinterpretation. Your questions should address any ambiquities, omissions, inconsistencies, vagueness, confusion, or unclarity in the problem requirements. Present your questions to the customer (or instructor) and use their feedback to write a more descriptive problem statement.
If you can't get feedback, do the best you can to determine the answers for yourself, and write a list of all the assumptions you make.
After you have thoroughly studied the problem and feel you understand completely what is being asked, you can rewrite the problem requirements in the form of a specification. The components of a specification are a description of the input data, the output data, and the functions the software is to perform. One method is to underline all the nouns in the problem statement -- these are the data items, and underline all the verbs -- these are the functions. Then write a description for each underlined word as a separate item (or "requirement") in the specification. Ideally, each statement in the specification is on a separate line with a line number for easy referencing by later documents (such as the test plan).
One caution: don't try to describe HOW to solve the problem, just describe WHAT the software will do. Only describe externally observable behavior.
Strive for clarity! A good specification is clear, precise, consistent,
understandable, unambiguous, and verifiable.
The english language often lacks the kind of precision of expression
necessary for describing computational and logical operations. For example,
can you think of three different interpretations for the simple question:
"Would you rather have a lion chase you or a bear?"
Below is a more realistic example of a requirement that might be found in the problem statement for a payroll system:
"Read in the day of the week and the number of hours worked."
Analysis questions:
Is the program to display some kind of prompting message asking for the input? What exactly should the prompt say?
Is day of the week to be spelled out fully, e.g. "tuesday," or can it be abbreviated? or both? what abbreviation, exactly? Is it case-sensitive?
Is number of hours an integer? a decimal number? how many decimal points?
There are only 24 hours in a day. What if hours entered is greater than 24? less than zero?
Are the day and hours to be entered on the same line? different lines? either?
In the case of a class assignment, its a good idea to double check with your instructor to ascertain that you have made the proper assumptions about the problem you are to solve.
It is nearly impossible to remove ALL the uncertainties in an english specification, so computer scientists have developed more formal methods of software specification that are beyond the scope of an introductory course. For this course, we will consider our analysis complete when we have a specification that is written clearly enough (in english) that no student has questions about what the problem requires. This will require a bit of judgement on your part to assess when your specifications are written precisely enough to effectively communicate the requirements to another student.
Refer to the following example as well as the case studies in the textbook
to get a sense of what constitutes a good specification.
Problem Statement
At a recent tortoise racing competition, your pet "Speedy" took first place. The judges at the race determined that Speedy's average rate of travel is one foot every ten seconds. Just for fun, you are curious how long it would take Speedy to travel around the world. Write a program that allows the user to enter a distance in miles, and computes Speedy's travel time.
Assumptions
Speedy's rate of travel is a constant within the program. The distance entered in miles should be a positive whole number. The maximum allowed distance is 99,999 miles. Input data which is invalid should cause an error message to be displayed and the program to terminate. The output should be a decimal number in hours, with two decimal places. The program should display an appropriate prompting message, read the user's input from the keyboard, and display the results on the screen with an explanatory remark. No checking is performed to see if the computations overflow the machine's allowable numeric range, and consequently invalid results may occur.
Input
An explanatory remark: "At a rate of one foot every ten seconds, it
would take Speedy _____ hours to travel ______ miles."
The number of hours (decimal number with 2 decimal places).
The travel distance (same value as input).
Functions
1. Display the prompt message.
2. Read the user's input of distance to travel, and verify the distance
is a valid number.
3. Compute travel time ( Distance divided by rate )
Given: Speedy rate = 1 ft / 10 sec
1 hour = 3600 sec
1 mile = 5280 feet
and user's input: Distance
formula for travel time is:
(Distance * 5280) / ( 3600 * ( 1 / 10 ))
4. Display the distance, travel time, and explanatory message.
Practice Analysis Problems
You can practice your analysis questioning and specification writing
on the sample problem statements below.
Write a program that is given your electric meter readings (in kilowatt-hours)
at the beginning and end of each month of the year. The program determines
your annual cost of electricity based on a charge of 6 cents per kilowatt-hours
for the first 1000 kilowatt-hours of each month and 8 cents per kilowatt-hour
beyond 1000. After printing out your total annual charges, the program
also determines if you used less than 500 kilowatt-hours for the entire
year and, if so, it prints out a message thanking you for conserving electricity.
Write a program that will determine the additional state tax owed by
an employee. The state charges a 4% tax on net income. Determine the net
income by subtracting a $500 allowance for each dependent from gross income.
Your program will read gross income, number of dependents, and tax amount
already deducted. It will then compute the actual tax owed and display
the difference between tax owed and tax deducted followed by the message
"SEND CHECK" or "REFUND", depending on whether this difference is positive
or negative.
The New Telephone Company has the following rate structure for long distance calls:
b. Any call started after 8:00 a.m. (0800 hours) but before 6:00 p.m.
(1800 hours) is charged full price.
c. All calls are subject to a 4% Federal tax.
d. The regular rate for a call is $0.40 per minute.
(From Programming and Problem Solving in Ada by Michael Feldman, Addison-Wesley,
1992).