Last week, we examined the facilities in each of our languages for creating an aggregate object -- an object made up of multiple values of arbitrary types. This week, we examine the facilities of each of our languages for making such objects and their operations reusable by storing them in a separately compiled module.
Modular programming is an extension of abstract data type (ADT) programming, in which a programmer decides what ADTs they need to solve their problem, builds them (usually using an aggregate), and encapsulates the ADT and its operations in a separately compiled module.
The module concept thus has two basic goals:
Some languages provide a separate module language construct; others have no construct but provide a mechanism for achieving similar results.
We will look at the module facility in each of our four languages. As in past weeks, we will do the same thing in each language, to compare their particular features. Our exercise will be to take our Name type from last week, and its operations, and store them in the "module" for each language. (You may want to review your text editor's "cut-and-paste" skills, since we will be "cutting" work from last week's program and "pasting" that work into a module.)
As usual, we will provide program "skeletons" that provide a framework for testing your work. Since the sole use of these programs will be to test our modules, they have no algorithms.
Also as usual, we will lead you through the process using Java, after which you will apply similar techiques to solve the problem in the other three languages. As usual, the order in which you do the three exercises does not matter.
Begin by making a new directory for this lab exercise and changing directory to that new directory.
Turn in. Each of the four parts requires you to create files containing source code and execution traces. When you have completed them, use cat to create a single file that contains all of your results:
cat java/script.java ada/script.ada clojure/script.clojure ruby/script.ruby > lab09-resultsThen submit your work by copying that single file into your personal folder in /home/cs/214/current/:
cp lab09-results /home/cs/214/current/yourUserName
replacing yourUserName with your login name.
The grader will access and grade your results from there.