DOC PREVIEW
UE CS 215 - Analysis and Design Style Guideline

This preview shows page 1-2-3 out of 8 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Specification for Temperature classCS 210 – Fundamentals of Programming IAnalysis and Design Style GuidelineThe purpose of the analysis and design is to outline a program before it is implemented. There are several reasons why this required. First, spending time writing out the analysis and design can greatly decrease the time it takes to implement a solution to a problem. The programmer is able to concentrate on what needs to be done to solve the problem rather than on the intricacies of the compiler or the syntax of the language of implementation. Second, often the person who designs the program is not the person who implements the program. As such, the analysis and design clearly documents what is needed to solve the problem without using code-specific jargon that the programmer may not be familiar with. In some cases, the implementation language is chosen after the analysis and design is completed.Analysis and Design for Main Programs and FunctionsAn analysis describes the data objects needed to solve the problem. It includes a description of the object, its type, whether it is a constant or a variable, and its name in the program. The analysis corresponds to the variable and constant declarations of a program. The analysis also describes the interfaces (the types of the argument and returned objects) of the functions used in the program (called function prototypes in C++), as well as the variables and constants that must be declared within the function.A design is the "outline" of the computational steps. It is often used synonymously with the term algorithm. There is a design for each function in a program as well as the main program itself. When implementing a function, the design corresponds to the executable statements needed to compute the result. The analysis and design format in this document is a shortened and modified version of the Object-Centered Design approach used in Adams, Leestma, and Nyhoff, C++: An Introduction to Computing, 2/e. Analysis for Main Programs and FunctionsThe main purpose of the analysis is to specify the objects that the program uses. Objects are data items that have values. They usually correspond to the nouns in the problem statement. For each object, we need to specify a description (what it is), its type (the class of values it might be), whether it is a constant or variable (its kind), and perhaps a name. In addition, for the objects used in functions, we need to specify the object's movement as received (in), returned (out), passed back (out), or local (no movement). There should an analysis for the main program, and each subprogram (function). It should be in the form of a table. For example, a main program analysis might look like: Objects Type Kind NameFahrenheit temperature double variable fahrenheitCelsius temperature double variable celsiusA function analysis might look like: Objects Type Kind Movement Namea verse of "The Farmer in the Dell" string constant local versea phrase string variable received restOfLineThe only difference between a function analysis and the main program analysis is that the main program does not have a movement column, since it does not take any arguments and its return value is not significant to the problem statement. All named objects should be listed, except the screen and the keyboard (cout and cin, respectively, in C++), since they appear in nearly every program. Unnamed objects (such as prompt and output strings) do 09/05/07 1 of 8not need to be listed unless used as a return value of a function. Global constants should be listed in the main program analysis.Design for Main Programs and FunctionsA design should list the main steps needed to solve the problem at hand. The steps should be numbered and the substeps should be subnumbered. Each step should be explained in the language of the problem. For the main function, this means that the steps are in the language of the original problem statement. For other functions, the steps are in the language of the subproblem being solved which is at a more detailed level than at the main program level. That is, we start describing how to compute the data item in question. But at the same time, if at this level, a step is better described abstractly rather than concretely, one would use a function to compute it and say so accordingly. The format for various design constructs are as follows: ● Input from keyboard1. Read in list of items to input Input from a file stream named inStream 1. Read in list of items to input from inStream● Output to screen 1. Display/print list of items to output Output to a file stream named outStream 1. Display/print list of items to output to outStream. ● Initialization1. Initialize aVariable to initial value. ● Computation using expression1. Compute aVariable = expression Note that an expression can be a single literal or variable. The computation should be expressed in English or standard mathematical notation, not in programming language notation. In particular, the use of C++ operators like ++ or *= is not appropriate. Instead, these computations might be expressed as1. Increment aVariable 2. Multiply aVariable by expression● Computation using a function that returns a value 1. Compute aVariable = ComputeSomething (list of arguments) Computation using a function that does not return a value 1. Compute something using ComputeSomething (list of arguments) 09/05/07 2 of 8● Function return 1. Return expressionAgain note that the return expression can be a single literal or variable. ● Branching selection. The condition and else are numbered consecutively. The bodies subnumbered accordingly. 1. If condition then 1.1. Do something 2. Else 2.1. Do something else Note that the condition can be any expression resulting in a boolean value. Also note that the else portion is optional.● Multi-way branch selection - each branch is numbered consecutively with bodies subnumbered accordingly. 1. If condition1 then 1.1. Do something1 2. Else if condition2 then 2.1. Do something2 3. Else 3.1. Do something else● Case selection - each case is subnumbered consecutively with case actions further subnumbered. 1. Select on anExpression 1.1. Case case 1 value 1.1.1. Do case 1 1.2. Case case 2 value 1.2.1. Do case 2● Counted repetition - header indicates loop control variable, starting value, stopping value, and step size (assumed to be 1 if omitted). Body is subnumbered. 1. For lcv from


View Full Document

UE CS 215 - Analysis and Design Style Guideline

Documents in this Course
Lecture 4

Lecture 4

14 pages

Lecture 5

Lecture 5

18 pages

Lecture 6

Lecture 6

17 pages

Lecture 7

Lecture 7

28 pages

Lecture 1

Lecture 1

16 pages

Lecture 5

Lecture 5

15 pages

Lecture 7

Lecture 7

28 pages

Load more
Download Analysis and Design Style Guideline
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Analysis and Design Style Guideline and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Analysis and Design Style Guideline 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?