Upload
tocho
View
54
Download
1
Tags:
Embed Size (px)
DESCRIPTION
Nifty Assignments: Marine Biology Simulation. Eric Cheng Mathias Ricken. Dung “Zung” Nguyen Stephen Wong. OOPSLA ‘04 Educators’ Symposium October 25, 2004. Marine Biology Simulation. Based on AP Marine Biology Simulation Completely redone using OO design - PowerPoint PPT Presentation
Citation preview
Nifty Assignments:Nifty Assignments:Marine Biology SimulationMarine Biology Simulation
OOPSLA ‘04 Educators’ SymposiumOOPSLA ‘04 Educators’ SymposiumOctober 25, 2004October 25, 2004
Eric ChengEric ChengMathias RickenMathias Ricken
Dung “Zung” NguyenDung “Zung” NguyenStephen 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 designMore 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: KnightFishAdd a new fish species to the simulationAdd a new fish species to the simulationPart 2: WrappingEnvPart 2: WrappingEnvAdd a new kind of environmentAdd a new kind of environment
Milestone 2Milestone 2Part 3: InternalsPart 3: InternalsRe-implement parts of the simulation frameworkRe-implement parts of the simulation frameworkPart 4: Behavior StrategiesPart 4: Behavior StrategiesRefactor 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, doneIf 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-statementsOOP: 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 processCannot forget to handle a situation (compiler Cannot forget to handle a situation (compiler error!)error!)
Part 2: WrappingEnvPart 2: WrappingEnvGrid-based, Grid-based, bounded, and bounded, and rectangular rectangular environmentenvironmentIf 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: WrappingEnvStudents learnStudents learn
To reuse existing code by subclassingTo reuse existing code by subclassingTo 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 projectRefactor a substantial portion of the codeRefactor a substantial portion of the codeExperience 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 / invariantsSolve 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 BehaviorPolymorphismPolymorphism
Design PatternsDesign PatternsUnit TestsUnit Tests
MBSMBS ~ end of 2nd semester.