Nifty Assignments Marine Biology Simulation Eric Cheng Mathias
Nifty Assignments: Marine Biology Simulation Eric Cheng Mathias Ricken OOPSLA ‘ 04 Educators’ Symposium October 25, 2004 Dung “Zung” Nguyen Stephen Wong
Marine Biology Simulation Based on AP Marine Biology Simulation Completely redone using OO design More robust, flexible, and extensible Two-week assignment in our objects-first CS 2 courses Requires broad range of skills Assignment and Source Code Available http: //www. owlnet. rice. edu/~comp 202
Marine Biology Simulation Demo
Structure of the Assignment Milestone 1 Part 1: Knight. Fish Add a new fish species to the simulation Part 2: Wrapping. Env Add a new kind of environment Support code Milestone 2 includes solution to Milestone 1 Part 3: Internals Re-implement parts of the simulation framework Part 4: Behavior Strategies Refactor framework to allow dynamic behavior changes
Part 1: Knight. Fish 1 2 8 3 7 4 6 5 Randomly pick one of 8 targets
Part 1: Knight. Fish 3 Turn into right direction For each step If blocked, done If open, go there and attempt the next step
Part 1: Knight. Fish Complicated behavior Procedural programming: nested if-statements OOP: nested visitors Visitor-Based Delegation Model Process flow diagramming makes designing complex algorithms a systematic process Cannot forget to handle a situation (compiler error!)
Part 2: Wrapping. Env Grid-based, bounded, and rectangular environment If the fish leaves on one side, it re -enters from the other side (toroidal)
Part 2: Wrapping. Env Students learn To reuse existing code by subclassing To integrate new code into a framework Students’ code still based on existing code But cannot simply be copied and modified anymore
Part 3: Internals Code missing in several places of the framework Students reimplement critical portions Gives students a tour of the entire framework Unit tests provide guidance Error messages in plain English
Part 4: Behavior Strategies Static Behavior! Separate the variants from the invariants + void move() Strategy Pattern + void move()
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 Requires new design and code that augments existing framework
Assignments in Objects-First Assignments have to be rich and deep Highlight benefits of object-orientation Large design portion Find proper abstractions, variants / invariants Solve family of problems Challenge to find suitable assignments Must be within students’ grasp Milestone 2 due today!
The Culmination of a Unified OO Pedagogy ~ end of 2 nd semester. MBS Unit Tests Design Patterns Polymorphism Abstract Structure and Behavior
- Slides: 14