Return to Jeff's Main Page

CS1 at Oswego

Hypertexknowlogy

Frequently Asked Questions

 
My Intro to Object-Oriented Programming  
 
 
 
Class Notes

Wednesday October 11 , 2000
 
The main topic of tonight's lecture was the ' Functional Application Architecture'.   The functional application architecture is the application architecture in which:
  1. All variables referenced in a method are declared local to the method.
  2. All methods defined in the class,  with the exception of the ``main'' method,  are operators.
Here is an example of the functional approach:

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

class LineOfSquaresFAA 

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

double figureArea = readFigureArea ();
int nrSquares = readNrOfSquares ();
double squareArea = computeSquareArea (figureArea,  nrSquares);
double squareSide = computeSquareSide (squareArea);
int eeCount = computeEECount (nrSquares);
double perimeter = computePerimeter (squareSide,  eeCount);
IO.println (``Perimeter =  ``+ perimeter);
} / /End of main method. 

static private double readFigureArea ()
{

IO.print (``Area of figure?   '');
return IO.read_double ();

static private int readNrOfSquares ()
{

IO.print (``How many squares?   '');
int nrOfSquares = IO.read_int ();
return nrSquares;

static private double computeSquareArea (double totalArea,  int nrSquares)
{

double sa = totalArea /nrSquares;
return sa;

static private double computeSquareSide (double areaOfSquare)
{

return Math.sqrt (areaOfSquare);

static private int computeEECount (int ns)
{

return (ns * 2) + 2;

static private double perimeter (double s,  int eeCount)
{

return s * eeCount;

 

CG gave a defintion for the objective application architecture,  but I have chosen to include it in the notes for October 16,  2000..