Lab 1 Class Functionality
Lab 1 Class Functionality
What is the purpose of a given class? That is, what is it (the class, the
method, the variable) for? ... why is it here?
This should help one to determine modularity and what "belongs" in a class
Consider the RangePerformanceTester.
Purpose: Given a number of implementations of a method (particularly the
range of a set of numbers), test and compare their performance.
What modules did I state?
SetGenerator
Timer
RangeFinder
ReportGenerator
the one everyone hates: RecordKeeper
(keep track of multiple runs of experiments and provide statistics)
When one does performance testing (in general) what is done
generate data
time data on a method
store result
compare results
print
How does this fit in with lab 1? What should the RangePerformanceTester do?
Who does what!? function
initialize itself
instantiate and initialize RecordKeeper
(to be able to store)
(put in Record instance as an IV)
instantiate Timer
instantiate RangeFinder
instantiate ReportGenerator
loop for set size
instantiate and call generator
loop for how many sets
call timer (will need to know method)
call RecordKeeper (i.e., storage)
(will need timer info & range result)
call reportGenerator
----------------------------------------------
Important: Where is information stored?
Early OO programmers want to pass everything as parameters.
Information should be kept in the object that the information is pertinent
to. Then the other objects (that want to use instances of this object) can
create their own instances and have access to the information via the instance.
Often pass instances rather than data. Also this
Also, very important:
what are classes?
what are instances?
A class defines what instances of a collection of things "starts out as".
As soon as you instantiate it, it is your instance. it holds your particular
information.
Instances are not reusable - they disappear after the run of the program.
However, one wants to set up objects so that others can use the same format
in the future...thus the class.
---------------------------------------------
Passing this
CreateArray ca = new CreateArray(this)
CreateArray(myprevious target){
outerparent = target; }
where outerparent is an IV for the class CreateArray (for which ca an instance)