Return to Jeff's Main Page

CS1 at Oswego

Hypertexknowlogy

Frequently Asked Questions

 
My Intro to Object-Oriented Programming  
 
 
 
Class Notes

Tuesday October 10 , 2000
 
After a discussion about this week's lab,  CG began a discussion about the ' Global Procedural Application Architecture'.   The global procedural application architecture is the application architecture in which:
  1. All variables which appear anywhere within the class are declared local to the class,  and hence are global to all of the methods of the class.
  2. All methods defined in the class are commands.
An operational procedure for writing an application consistent with a the global procedural application architecture:
  1. Sketch a main method which hypothesizes the existence of commands which do what needs to be done.
  2. Add to ` 1 ' a ``data dictionary'' which associates variables with the concepts introduced in the main method.
  3. Refine the commands hypothesized in the main method in such a way that they ``fit in'' with the data dictionary.
The following is an example of the global procedural application architecture:

A line of n-congruent squares collectively has area a.   What is the perimeter of the line of squares? 

class LineOfSquaresGPAA 

static public void main (~ ~ ~ ~ ~ ~)
{

readProblemParameters ();
computeAreaOfOneSquare;
computeLengthOfSide ();
computeNumberOfExternalEdges ();
compute perimeter;
displayPerimeter ();

/ /The data dictionary.
static private double figureArea;
static private int nrSquares;
static private double squareArea;
static private double sideLength;
static private int eeCount;
static private double perimeter; 

static private void readProblemParameters ()
{

IO.print (``Area of figure?   '');
figureArea = IO.read_double ();
IO.print (``Number of squares?   '');
nrSquares = IO.read_int ();

static private void computeAreaOfOneSquare ()
{

squareArea = figureArea /nrSquares;

static private void computeLengthOfOneSide ()
{

sideLength = Math.sqrt (squareArea);

static private void computeNumberOfExternalEdges ()
{

eeCount = (nrSquares * 2) + 2;

static private void computePerimeter ()
{

perimeter = eeCount * sideLength;

static private void displayPerimeter ()
{

IO.println (``Perimeter is ``+ perimeter);