marine biology simulation part i: introduction
Post on 23-Mar-2016
24 Views
Preview:
DESCRIPTION
TRANSCRIPT
Marine Biology SimulationMarine Biology SimulationPart I: IntroductionPart I: Introduction
Dung “Zung” NguyenDung “Zung” NguyenMathias RickenMathias RickenStephen WongStephen Wong
TeachJava 2004!TeachJava 2004!June 25, 2004June 25, 2004
The Role of ProgrammingThe Role of Programming
Important skillImportant skillShould be taught early in a student’s careerShould be taught early in a student’s career
Usually taught Usually taught imperative-firstimperative-firstConcentrates on language elements like Concentrates on language elements like expressions, operators, functions, pointers…expressions, operators, functions, pointers…
Problems Teaching Imperative-FirstProblems Teaching Imperative-FirstFocus on syntactical elements Focus on syntactical elements
Exercises too simple to be motivatingExercises too simple to be motivating
Too little emphasis on designToo little emphasis on design
Biased against students without prior Biased against students without prior knowledgeknowledge
Object-OrientationObject-Orientation
Beneficial to software qualityBeneficial to software qualityCorrect, robust, flexible, and extensibleCorrect, robust, flexible, and extensible
Extensively covers software designExtensively covers software design
Examples are more challenging and Examples are more challenging and motivatingmotivating
Usually considered “advanced concept”Usually considered “advanced concept”
AssignmentsAssignments
Assignments have to be complexAssignments have to be complexHighlight 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 assignmentsExample: Marine Biology SimulationExample: Marine Biology Simulation
AP Marine Biology SimulationAP Marine Biology Simulation
Case studies in AP curriculum since 1994Case studies in AP curriculum since 1994Argument:Argument:““Some good reasons to use a case study in AP Some good reasons to use a case study in AP
Computer Science include:Computer Science include:• Working with a program of significant lengthWorking with a program of significant length• Thinking through issues of good program Thinking through issues of good program
designdesign• Learning from an expert programmer”Learning from an expert programmer”
(AP Marine Biology Simulation Case Study – Teacher’s Manual)(AP Marine Biology Simulation Case Study – Teacher’s Manual)
AP Marine Biology SimulationAP Marine Biology Simulation
Goal:Goal:““Through the Through the AP Marine Biology Simulation Case AP Marine Biology Simulation Case
StudyStudy, the strategies, vocabulary, and , the strategies, vocabulary, and techniques of object-oriented design will be techniques of object-oriented design will be emphasized.”emphasized.”
(AP Marine Biology Simulation Case Study – Teacher’s Manual)(AP Marine Biology Simulation Case Study – Teacher’s Manual)
ShortcomingsShortcomingsImproper abstractions, incorrect delineation of Improper abstractions, incorrect delineation of responsibilitiesresponsibilitiesTight couplingTight coupling
not robustnot robust not flexible and extensiblenot flexible and extensible
AP Marine Biology SimulationAP Marine Biology Simulation
DemoDemo
AP Marine Biology SimulationAP Marine Biology Simulation
Unenforceable contracts
Insecure architecture
a few pitfalls...a few pitfalls...
Key issue:Key issue:Limited extensibility
Replicated data
Tight CouplingTight Coupling
Where am I?Where am I?
Latitude = 29.65 Longitude = 95.28
On some global coordinate grid?On some global coordinate grid?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?
Think Simple.Think Simple.I know where I am: right I know where I am: right herehere..
X
X
Which is Which is notnot the same as the same as herehere..
X
And And notnot the same as the same as herehere either. either.
Each fish has its Each fish has its ownown local local environmentenvironment
XX
XX
X
The local environment is an The local environment is an indirection layer between the fish indirection layer between the fish
and the global environment.and the global environment.
Fish and their EnvironmentFish and their EnvironmentA fish has a local
environmentThe local
environment provides services
to the fish
The local environment does NOT provide x-y
coordinates!
The local environment is
instantiated by the global environment
Factory Method Design Pattern
Local environment communicates with global environment
but fish do not.
A Fish’s DilemmaA Fish’s Dilemma
Unblocked!Blocked!
Can I move forward?Can I move forward?Send a message to the Send a message to the local environment!local environment!
Blocked case commandBlocked case commandUnblocked case commandUnblocked case commandSend commands to Send commands to local environmentlocal environment
The appropriate command is selectedThe appropriate command is selectedThe fish responds accordingly!The fish responds accordingly!
X
Or…Or…The appropriate command is selectedThe appropriate command is selectedLocal environment makes a Local environment makes a move commandmove command
Move command sent to fishMove command sent to fishIf desired, fish applies move command If desired, fish applies move command
MoveCommand
Unblocked!
Blocked!X
A fish can ONLY move as
prescribed by its environment!
A fish does not need to know A fish does not need to know its x-y coordinate! its x-y coordinate!
A fish does not need to know A fish does not need to know “how” to move!“how” to move!
A fish is decoupled from the A fish is decoupled from the global environment!global environment!
Fish-Environment InteractionFish-Environment Interaction
_localEnv.tryMoveFwd(this,
,
);
SimpleFish Class
new ILambda() { public Object apply(Object moveCmd) { ((ILambda)moveCmd).apply(null); return null; }}
Command to execute if blocked
Command to execute if unblocked
new ILambda() { public Object apply(Object notUsed) { turnRight(Math.PI); return null; }}
Delegate to the local environment
Fish-Environment InteractionFish-Environment Interaction
Code is used in a class assignmentand has been removed
LocalEnvironment Class Make local environment in the direction the fish
wants to move… either make a command that actually moves
the fish…
Depending on whether the new
local environment is empty or not…
… and execute the unblocked command
… or execute the blocked command
Design BenefitsDesign Benefits
Replaceable Replaceable environmentsenvironmentsDifferent fishDifferent fishRobustnessRobustness
Decoupled, abstract designDecoupled, abstract designEnhanced capabilitiesEnhanced capabilities
Rice Marine Biology SimulationRice Marine Biology Simulation
DemoDemo
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.
Problems Using This in AP ClassesProblems Using This in AP Classes
Defined curriculumDefined curriculum
Students must perform well in examsStudents must perform well in examsTeach what exams requireTeach what exams require
Current curriculum disagrees with our Current curriculum disagrees with our approachapproach
Rice MBS is for university-level classesRice MBS is for university-level classes
ResultsResults
Addresses problems Addresses problems of imperative-firstof imperative-first
Focus on designFocus on designMotivating Motivating assignmentsassignments
Not biased againstNot biased againstLack of experienceLack of experienceGenderGenderDeclared MajorDeclared MajorYear in SchoolYear in SchoolSAT ScoresSAT Scores
Objects-first is programming for everyoneObjects-first is programming for everyone
AP curriculum will hopefully changeAP curriculum will hopefully change
Future WorkFuture Work
Make simulation guarantee progressMake simulation guarantee progressPrevent one fish from blocking othersPrevent one fish from blocking others
Extra credit competition using MBSExtra credit competition using MBSGame of life, outbreed other species?Game of life, outbreed other species?
Study MBS along several cognitive Study MBS along several cognitive dimensionsdimensions
Improve assignment qualityImprove assignment quality
top related