Due date: 2/17 : 11PM (code walked next day)
Objective 1: to design and implement contracts for the board and the
Objective 2: to give you some time to catch up. Some of you had
trouble with projects 4 and 5. In my experience, the trouble is due to
two failures to follow the design recipe. First, people fail to think
carefully about the contracts for their visible functions or methods.
Second, they tend to formulate tests at the end of the project period
instead of the beginning. This week is your chance to fix both problems.
Task 0: It is time to re-organize. In projects 4 and 5
you were asked to design and implement two components: the board and the
turn. You were also asked to imagine that human players and
human rule enforcers (aka, administrators) use these pieces of
software to facilitate their game playing.
If you implemented extraneous pieces, it is now time to eliminate them.
You have no need for players, administrators, etc. Period.
You may have a need for the common vocabulary, e.g., tiles, coordinates,
etc. That's fine and driven by the original demand.
Your test harness may come with components that simulate actions that
could end up in a player module or an administrator class. That's fine;
reuse them when/if the time comes to implement these components.
Protecting Components: You have designed and
implemented two components that need to interact with each other and with
other components (players, administrators) yet to be designed. It is now
time to formulate interfaces with contracts for your components. Doing so
should ensure that the interface clearly communicates the purpose of the
main functions; that it is expressive, which leads to the proper
allocation of knowledge and responsibilities; and that your components
become more robust.
Task 1: Write down a precise interface specification
("types" with contracts, if needed) for your board's and your turn's
externally visible pieces of functionality. Supplement them as needed with
additional pieces of functionality so you can state checkable contracts.
Task 2: Implement both interfaces using contract
systems for your chosen language or hand-coded contract implementations
(see lecture for the protocol).
Note: In principle, a contract system is only sound if it is
"baked" into the underlying programming language. Many contract systems
come as third-party code (in the form of a library that uses run-time
reflection, meta-protocols, or macro technology). Such libraries may on
occasion blame the wrong party or may not even discover a contract
violation. You should know that but using such libraries is still
acceptable for the course.
Task 3: You are to provide ten tests each for the board
and turn component. For the specification of test cases, see projects 4
and 5. If you believe that your tests for these projects stress the board
and turn implementations appropriately, there is no need to change them;
just copy them over. Otherwise, this is an opportunity to catch up with
Test Fest: As always, we will conduct a "test fest"
using your code and the tests that you provide.
Deliverables: Your SVN directory must contain a
subdirectory labeled "06" with the following pieces:
For the description of the four scripts, see projects
Note: For security reasons, your script will run on a machine that is
disconnected from the network.