



|
|
Byron's CSC212 Web Site
|
Class Notes
Wednesday October 11 , 2000
|
|
|
Functional Application Architecture
Class Notes --
Wednesday October 11 , 2000
CSC212 - October 11, 2000
========================
Lecture Topic: Functional Application Architecture
DEF: 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 notable
exception of "main" are operators.
The "Functional" approach:
class ----------
{
static public void main (-----)
{
double figureArea = IO.readFigureArea();
int nrSquares = read nrOfSquares();
double squareArea = computeSquareArea(figureArea,n+
rSquares);
double squareSide = computeSquareSide(squareArea);
int eeCount = computeEECount(nrSquares);
double perimeter = computePerimeter(squareSide,eeC+
ount);
IO.println("Perimeter = " + perimeter);
} // End of Main Method
// Class Method
// Operator
static private double readFigureArea()
{
// Prompt
IO.print("Total Figure Area? ");
return IO.read_double();
}
static private int readNrOFSquares()
{
IO.print("How Many Squares? ");
int nrOfSquares = IO,read_int();
return nrOFSquares;
}
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)
// ns = nrSides
{
return (ns * 2) + 2;
}
static private double perimeter(double s,int eeCount)
{
return s * eeCoount;
}
}
Main Method Environment:
figureArea -> 27
nrSquares -> 3
squareArea -> 9
perimeter -> ?
Compute Square Area Environment: (Parameters)
Note - These values go away when program complete.
totalArea -> 27
nrSquares -> 3
sa -> 9.0
==========================================================+
123456789012345678921234567893123456789412345678951234567
|
|
|