110 likes | 128 Vues
Marine Biology Simulation Part III: Assignment, Milestone 2. Dung “Zung” Nguyen Mathias Ricken Stephen Wong. TeachJava 2004! June 25, 2004. Rice MBS Assignment. Milestone 1 Part 1: KnightFish Add a new fish species to the simulation Part 2: WrappingEnv Add a new kind of environment
E N D
Marine Biology SimulationPart III: Assignment, Milestone 2 Dung “Zung” Nguyen Mathias Ricken Stephen Wong TeachJava 2004! June 25, 2004
Rice MBS Assignment • Milestone 1 • Part 1: KnightFish Add a new fish species to the simulation • Part 2: WrappingEnv Add a new kind of environment • Milestone 2 • Part 3: Internals Re-implement parts of the simulation framework • Part 4: Behavior Strategies Refactor framework to allow dynamic behavior changes
Preparation • Download materials for Milestone 2 • milestone2.zip • Unzip into empty directory • Open DrJava • Copy your drjava.jar into the project directory • Remove RiceMBSfw.jar from “Extra Classpath”
Part 3: Internals • Open the DrJava_Test_* files tests package • Hit the test button • Several tests will fail • Critical portions of the framework have been removed • Tests provide students with feedback • Guide the way without giving away the answer • Better error messages than just “NullPointerException” and the like
Part 3: Internals • Code missing in several places of the framework • Fish • Local environment • Global environment • Gives students a tour of the entire framework
Re-implement as per given specs. Re-implement as per given specs. Part 3: Internals Unit tests guide the way
Part 3: Internals • Students gain insight into • Abstraction and loose coupling • Message passing • Writing large frameworks • Working with someone else’s code • Requires extensive work within existing framework • At the end of this part, students have completely restored the original functionality
Part 4: Behavior Strategies • Once students have understood the existing framework, they can improve it • Point out one of the flaws • Fish cannot change behavior • This part involves refactoring the old code and creating a new class hierarchy
+ void move() + void move() + void move() Part 4: Behavior Strategies Separate the variants from the invariants Strategy Pattern
Part 4: Behavior Strategies • Students have the opportunity to • Apply design patterns to improve the project • Refactor a substantial portion of the code • Experience how loose coupling makes this easy • Use unit tests to protect against previous bugs • Maintain documentation • Requires new design and code that augments existing framework • At the end of the assignment, students will have added a major feature to the simulation
Summary • Students slowly gain experience with the framework • Parts 1 and 2 provides a lot of support • Part 3 gives students more responsibility, but unit tests provide guidance • Part 4 gives students freedom to design and improve • Compelling and entertaining example of object-oriented design