|
|
||||||
Due Sun. Oct. 1, 11:59 PMAnother week, another abstraction...... This week we will utilize the idea of "information hiding" to push our BallWorld to an even higher level of abstraction. We will package the entire animation process up into an object (hmmm...wasn't there something about "behavior as an object"?) that we will sequester behind the walls of a "package", exposing only the barest minimum to the client that utilizes its capabilities. The concept of packaging is part of a larger issue called "scoping". The scoping of an object, variable, or method determines who (what other objects) can "see" it and thus who can use it. This will enable us to have variables and methods that are strictly for internal use and thus do not affect the outward behavior contracts that the object presents to the rest of the program. It will also allow us to package groups of objects into pseudo-objects with controlled externally visible behaviors. In the second section, we will explore the Strategy design pattern and how the separation of the variant and invariant behaviors of the Ball class will enable us to eliminate the entire subclass structure of Ball, but yet add tremendous flexibility and capability to the system. Simpler can mean better and more powerful. We will also explore the Null Object and Decorator design patterns that work hand in hand with our usage of the Strategy design pattern. Complete the first section on scoping before proceeding to the second section. Ask your lab assistants and/or instructor for assistance if your get bogged down. Try very hard to get well into the second section during the laboratory period. Have fun! Laboratory written by Stephen Wong |