Presentation is loading. Please wait.

Presentation is loading. Please wait.

Marine Biology Simulation Part I: Introduction

Similar presentations


Presentation on theme: "Marine Biology Simulation Part I: Introduction"— Presentation transcript:

1 Marine Biology Simulation Part I: Introduction
Dung “Zung” Nguyen Mathias Ricken Stephen Wong TeachJava 2004! June 25, 2004

2 The Role of Programming
Important skill Should be taught early in a student’s career Usually taught imperative-first Concentrates on language elements like expressions, operators, functions, pointers… The Role of Programming: Vital skill Should be mastered early Usually taught imperative-first

3 Problems Teaching Imperative-First
Focus on syntactical elements Exercises too simple to be motivating Too little emphasis on design Biased against students without prior knowledge Problems Teaching Imperative-First: Focus on syntax Bias against students without prior programming experience Oversimplifies programming Little focus on design, documentation, testing Not motivation

4 Object-Orientation Beneficial to software quality
Correct, robust, flexible, and extensible Extensively covers software design Examples are more challenging and motivating Usually considered “advanced concept” Objects-First Beneficial for software quality Covers more topics: design, implementation, testing, documentation More complex examples

5 Assignments Assignments have to be complex Large design portion
Highlight benefits of object-orientation Large design portion Find proper abstractions, variants / invariants Solve family of problems Challenge to find suitable assignments Example: Marine Biology Simulation

6 AP Marine Biology Simulation
Case studies in AP curriculum since 1994 Argument: “Some good reasons to use a case study in AP Computer Science include: Working with a program of significant length Thinking through issues of good program design Learning from an expert programmer” (AP Marine Biology Simulation Case Study – Teacher’s Manual)

7 AP Marine Biology Simulation
Goal: “Through the AP Marine Biology Simulation Case Study, the strategies, vocabulary, and techniques of object-oriented design will be emphasized.” (AP Marine Biology Simulation Case Study – Teacher’s Manual) Shortcomings Improper abstractions, incorrect delineation of responsibilities Tight coupling  not robust  not flexible and extensible

8 AP Marine Biology Simulation
Demo

9 AP Marine Biology Simulation
a few pitfalls... Insecure architecture Replicated data Unenforceable contracts Limited extensibility Key issue: Tight Coupling

10 X X X Which is not the same as here. On some global coordinate grid?
And not the same as here either. Where am I? I know where I am: right here. Think Simple. Do I know my own coordinates? Does anyone else know my coordinates? Should I know anyone else’s coordinates? Do I really care where Greenwhich is? To change my location is to change my LOCAL environment. Knowing my location does NOT mean I know my global coordinate! ? X X X Latitude = 29.65 Longitude = 95.28

11 Each fish has its own local environment
The local environment is an indirection layer between the fish and the global environment. X X X X X The local environment decouples the fish from the global environment.

12 Fish and their Environment
The local environment provides services to the fish A fish has a local environment Local environment communicates with global environment but fish do not. The local environment is instantiated by the global environment The local environment does NOT provide x-y coordinates! Factory Method Design Pattern Decoupled, robust & secure behavior!

13 X The fish responds accordingly! Send commands to local environment
Unblocked case command A Fish’s Dilemma The appropriate command is selected Blocked case command Can I move forward? Send a message to the local environment! ? Unblocked! Blocked! X

14 A fish can ONLY move as prescribed by its environment!
Local environment makes a move command Move command sent to fish If desired, fish applies move command Or… The appropriate command is selected ? A fish can ONLY move as prescribed by its environment! X Move Command Unblocked! Blocked!

15 A fish does not need to know its x-y coordinate!
A fish does not need to know “how” to move! Decoupled, yet interactive behavior! A fish is decoupled from the global environment!

16 Fish-Environment Interaction
Delegate to the local environment SimpleFish Class new ILambda() { public Object apply(Object notUsed) { turnRight(Math.PI); return null; } _localEnv.tryMoveFwd(this, , ); Command to execute if blocked new ILambda() { public Object apply(Object moveCmd) { ((ILambda)moveCmd).apply(null); return null; } Command to execute if unblocked

17 Fish-Environment Interaction
Depending on whether the new local environment is empty or not… Fish-Environment Interaction Make local environment in the direction the fish wants to move LocalEnvironment Class public Object tryMoveFwd(AFish f, ILambda blocked, ILambda unblocked) { ILocalEnv le = makeMoveFwdLocalEnv(); return le.execute(new ILocalEnvVisitor() { public Object emptyCase(ILocalEnv h, Object nu) { ILambda moveCmd = new MoveLambda(le); return unblocked.apply(moveCmd); } public Object nonEmptyCase(ILocalEnv h, Object nu) { return blocked.apply(null); }, null); … either make a command that actually moves the fish… … and execute the unblocked command … or execute the blocked command No if-statements!

18 Design Benefits Decoupled, abstract design Enhanced capabilities
Replaceable environments Different fish Robustness

19 Rice Marine Biology Simulation
Demo

20 The Culmination of a Unified OO Pedagogy
MBS ~ end of 2nd semester. Unit Tests Design Patterns Polymorphism Abstract Structure and Behavior

21 Problems Using This in AP Classes
Defined curriculum Students must perform well in exams Teach what exams require Current curriculum disagrees with our approach Rice MBS is for university-level classes

22 Results Objects-first is programming for everyone
Addresses problems of imperative-first Focus on design Motivating assignments Not biased against Lack of experience Gender Declared Major Year in School SAT Scores AP curriculum will hopefully change

23 Future Work Make simulation deadlock-safe
Extra credit competition using MBS Game of life, outbreed other species? Study MBS along several cognitive dimensions Improve assignment quality


Download ppt "Marine Biology Simulation Part I: Introduction"

Similar presentations


Ads by Google