nifty assignments: marine biology simulation

14
Nifty Assignments: Nifty Assignments: Marine Biology Marine Biology Simulation Simulation OOPSLA ‘04 Educators’ Symposium OOPSLA ‘04 Educators’ Symposium October 25, 2004 October 25, 2004 Eric Cheng Eric Cheng Mathias Ricken Mathias Ricken Dung “Zung” Nguyen Dung “Zung” Nguyen Stephen Wong Stephen Wong

Upload: tocho

Post on 25-Feb-2016

54 views

Category:

Documents


1 download

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

TRANSCRIPT

Page 1: Nifty Assignments: Marine Biology Simulation

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

Page 2: Nifty Assignments: Marine Biology Simulation

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

Page 3: Nifty Assignments: Marine Biology Simulation

Marine Biology SimulationMarine Biology Simulation

DemoDemo

Page 4: Nifty Assignments: Marine Biology Simulation

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

Page 5: Nifty Assignments: Marine Biology Simulation

Part 1: KnightFishPart 1: KnightFish

Randomly pick Randomly pick one of 8 targetsone of 8 targets

11 22

33

44

5566

77

88

Page 6: Nifty Assignments: Marine Biology Simulation

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

Page 7: Nifty Assignments: Marine Biology Simulation

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!)

Page 8: Nifty Assignments: Marine Biology Simulation

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)

Page 9: Nifty Assignments: Marine Biology Simulation

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

Page 10: Nifty Assignments: Marine Biology Simulation

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

Page 11: Nifty Assignments: Marine Biology Simulation

Strategy Pattern

+ void move()

+ void move() + void move()

Static Behavior! Separate the variants from the invariants

Part 4: Behavior StrategiesPart 4: Behavior Strategies

Page 12: Nifty Assignments: Marine Biology Simulation

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

Page 13: Nifty Assignments: Marine Biology Simulation

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!

Page 14: Nifty Assignments: Marine Biology Simulation

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.