nifty assignments: marine biology simulation oopsla ‘04 educators’ symposium october 25, 2004...
Post on 13-Jan-2016
218 Views
Preview:
TRANSCRIPT
Nifty Assignments:Nifty Assignments:Marine Biology SimulationMarine Biology Simulation
OOPSLA ‘04 Educators’ SymposiumOOPSLA ‘04 Educators’ Symposium
October 25, 2004October 25, 2004
Eric ChengEric Cheng
Mathias RickenMathias Ricken
Dung “Zung” NguyenDung “Zung” Nguyen
Stephen WongStephen Wong
Marine Biology SimulationMarine Biology Simulation
Based on AP Marine Biology SimulationBased on AP Marine Biology SimulationCompletely redone using OO designCompletely redone using OO design
More robust, flexible, and extensibleMore robust, flexible, and extensible
Two-week assignment in our objects-first Two-week assignment in our objects-first CS2 coursesCS2 courses
Requires broad range of skillsRequires broad range of skills
Assignment and Source Code AvailableAssignment and Source Code Availablehttp://www.owlnet.rice.edu/~comp202http://www.owlnet.rice.edu/~comp202
Marine Biology SimulationMarine Biology Simulation
DemoDemo
Structure of the AssignmentStructure of the Assignment
Milestone 1Milestone 1Part 1: KnightFishPart 1: KnightFish
Add a new fish species to the simulationAdd a new fish species to the simulation
Part 2: WrappingEnvPart 2: WrappingEnv
Add a new kind of environmentAdd a new kind of environment
Milestone 2Milestone 2Part 3: InternalsPart 3: Internals
Re-implement parts of the simulation frameworkRe-implement parts of the simulation framework
Part 4: Behavior StrategiesPart 4: Behavior Strategies
Refactor framework to allow dynamic behavior changesRefactor framework to allow dynamic behavior changes
Support code includes
solution to Milestone 1
Part 1: KnightFishPart 1: KnightFish
Randomly pick Randomly pick one of 8 targetsone of 8 targets
11 22
33
44
5566
77
88
Part 1: KnightFishPart 1: KnightFish
Turn into right Turn into right directiondirection
For each stepFor each stepIf blocked, doneIf blocked, done
If open, go there If open, go there and attempt the and attempt the next stepnext step
33
Part 1: KnightFishPart 1: KnightFish
Complicated behaviorComplicated behaviorProcedural programming: nested if-statementsProcedural programming: nested if-statements
OOP: nested visitorsOOP: nested visitors
Visitor-Based Delegation ModelVisitor-Based Delegation ModelProcess flow diagramming Process flow diagramming makes designing makes designing complex algorithms a systematic processcomplex algorithms a systematic process
Cannot forget to handle a situation (compiler Cannot forget to handle a situation (compiler error!)error!)
Part 2: WrappingEnvPart 2: WrappingEnv
Grid-based, Grid-based, bounded, and bounded, and rectangular rectangular environmentenvironment
If the fish leaves If the fish leaves on one side, it on one side, it re-enters from re-enters from the other side the other side (toroidal)(toroidal)
Part 2: WrappingEnvPart 2: WrappingEnv
Students learnStudents learnTo reuse existing code by subclassingTo reuse existing code by subclassing
To integrate new code into a frameworkTo integrate new code into a framework
Students’ code still based on existing Students’ code still based on existing codecode
But cannot simply be copied and modified But cannot simply be copied and modified anymoreanymore
Part 3: InternalsPart 3: InternalsCode missing in several places of the Code missing in several places of the frameworkframework
Students reimplement critical portionsStudents reimplement critical portionsGives students a tour of the entire frameworkGives students a tour of the entire framework
Unit tests provide guidanceUnit tests provide guidanceError messages in plain EnglishError messages in plain English
Strategy Pattern
+ void move()
+ void move() + void move()
Static Behavior! Separate the variants from the invariants
Part 4: Behavior StrategiesPart 4: Behavior Strategies
Part 4: Behavior StrategiesPart 4: Behavior Strategies
Students have the opportunity toStudents have the opportunity toApply design patterns to improve the projectApply design patterns to improve the project
Refactor a substantial portion of the codeRefactor a substantial portion of the code
Experience how loose coupling makes this easyExperience how loose coupling makes this easy
Requires new design and code that Requires new design and code that augments existing frameworkaugments existing framework
Assignments in Objects-FirstAssignments in Objects-FirstAssignments have to be rich and deepAssignments have to be rich and deep
Highlight benefits of object-orientationHighlight benefits of object-orientation
Large design portionLarge design portionFind proper abstractions, variants / invariantsFind proper abstractions, variants / invariants
Solve family of problemsSolve family of problems
Challenge to find suitable assignmentsChallenge to find suitable assignmentsMust be within students’ graspMust be within students’ grasp
Milestone 2 due today!Milestone 2 due today!
The Culmination of a The Culmination of a Unified OO PedagogyUnified OO Pedagogy
Abstract Structure and BehaviorAbstract Structure and Behavior
PolymorphismPolymorphism
Design PatternsDesign Patterns
Unit TestsUnit Tests
MBSMBS ~ end of 2nd semester.
top related