Nifty Assignments: Marine Biology Simulation - PowerPoint PPT Presentation

About This Presentation
Title:

Nifty Assignments: Marine Biology Simulation

Description:

Mathias Ricken. Dung 'Zung' Nguyen. Stephen Wong. Marine Biology Simulation ... Two-week assignment in our objects-first CS2 courses. Requires broad range of skills ... – PowerPoint PPT presentation

Number of Views:35
Avg rating:3.0/5.0
Slides: 15
Provided by: steph173
Category:

less

Transcript and Presenter's Notes

Title: Nifty Assignments: Marine Biology Simulation


1
Nifty AssignmentsMarine Biology Simulation
  • Eric Cheng
  • Mathias Ricken

Dung Zung Nguyen Stephen Wong
OOPSLA 04 Educators Symposium October 25, 2004
2
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 CS2
    courses
  • Requires broad range of skills
  • Assignment and Source Code Available
  • http//www.owlnet.rice.edu/comp202

3
Marine Biology Simulation
Demo
4
Structure of the 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

Support code includes solution to Milestone 1
5
Structure of the Assignment
White-box Framework Extension by Subclassing
Variant Fish Behavior
Variant Environment Behavior
6
Part 1 KnightFish
  • Randomly pick one of 8 targets

1
2
3
8
4
7
5
6
7
Part 1 KnightFish
  • Turn into right direction
  • For each step
  • If blocked, done
  • If open, go there and attempt the next step

3
8
Part 1 KnightFish
  • Moves almost like a knight, except
  • No jumping
  • If blocked, may stop on the way

3
Stop here
9
Part 1 KnightFish
  • 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!)

10
Part 2 WrappingEnv
  • Grid-based, bounded, and rectangular environment
  • If the fish leaves on one side, it re-enters from
    the other side (toroidal)

11
Part 2 WrappingEnv
  • 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

12
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

13
Part 3 Internals
  • Students gain insight into
  • Abstraction and loose coupling
  • Message passing
  • Writing large frameworks
  • Working with someone elses code
  • Requires extensive work within existing framework

14
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

15
Part 4 Behavior Strategies
Static Behavior!
Separate the variants from the invariants
Strategy Pattern
Dynamic Behavior Change
16
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

17
Summary
  • Students slowly gain experience with the
    framework
  • Parts 1 and 2 provide 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

18
Niftiness
  • Large, non-trivial project
  • Focus on the design of OO systems
  • Flexible yet secure design
  • Can be used for other applications, e.g. OS
  • Test-driven development
  • Provides feedback, but not the answer

19
Niftiness
  • Requires broad set of skills
  • Inheritance, delegation
  • Unit testing
  • Reading and writing documentation
  • Design patterns
  • Refactoring
  • Components and frameworks
  • Flexibility and extensibility reinforce power of
    OO design
  • Entertaining, visual project

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

21
The Culmination of a Unified OO Pedagogy
end of 2nd semester.
MBS
Unit Tests
Design Patterns
Polymorphism
Abstract Structure and Behavior
Write a Comment
User Comments (0)
About PowerShow.com