Date post: | 26-Dec-2015 |
Category: |
Documents |
Upload: | grant-west |
View: | 219 times |
Download: | 0 times |
Case Study as Educational Tool
describes a real situationdescribes a real situation provides an interesting example from which provides an interesting example from which
to draw certain lessonsto draw certain lessons provides a context for comparing theoretical provides a context for comparing theoretical
ideas against real-world experienceideas against real-world experience
Case Studies in AP CS
try to give the illusion of being a real-world try to give the illusion of being a real-world situation (MBCS) or real-world tool situation (MBCS) or real-world tool (BigInt)(BigInt)
must be simplified and cleaned-up enough must be simplified and cleaned-up enough to be readable and understandable for HS to be readable and understandable for HS studentsstudents
Benefits of an AP CS case study
example of a largish program example of a largish program opportunity to discuss tradeoffs (design, opportunity to discuss tradeoffs (design,
performance issues, readability, etc)performance issues, readability, etc) example of good coding, design, and example of good coding, design, and
documentation practicedocumentation practice approximation of master/apprenticeapproximation of master/apprentice rich source of assignments rich source of assignments source of non-trivial exam questionssource of non-trivial exam questions
Alyce’s Additions
describe the development or modification of describe the development or modification of a program, not just a finished producta program, not just a finished product
cover designcover design cover testingcover testing
Goals for Java MBS
provide benefits described in prev. slidesprovide benefits described in prev. slides be similar to C++ MBCSbe similar to C++ MBCS
teachers can pick it up faster can use it as they learn Java
be different from C++ MBCSbe different from C++ MBCS highlight differences in languagehighlight differences in language highlight differences in curriculumhighlight differences in curriculum
The Story A CS student, Pat, gets a summer job working for A CS student, Pat, gets a summer job working for
marine biologists.marine biologists. Hired to enhance an existing program that Hired to enhance an existing program that
simulates fish movement in a bounded simulates fish movement in a bounded environment.environment. Needs to understand existing programNeeds to understand existing program Designs, codes, and tests modificationsDesigns, codes, and tests modifications
Occasionally Pat turns to an experienced Occasionally Pat turns to an experienced programmer, Jamie, for help.programmer, Jamie, for help.
Narrative is Pat’s report of summer job.Narrative is Pat’s report of summer job.
The Package
Code for the “existing” programCode for the “existing” program Source for core classesSource for core classes Jar files for “black box” & GUI classesJar files for “black box” & GUI classes
Javadoc documentation for most classesJavadoc documentation for most classes Data FilesData Files Instructions for compiling/runningInstructions for compiling/running Narrative (pdf file)Narrative (pdf file)
The Modules (Chapters)
Experiment with existing programExperiment with existing program Guided tour of existing program by JamieGuided tour of existing program by Jamie Add breeding and dyingAdd breeding and dying Add two new kinds of fish (inheritance)Add two new kinds of fish (inheritance)
Provide alternative representations Provide alternative representations (unbounded environment, others)(unbounded environment, others)
First Day on the Job
““[The program] was designed to help the [The program] was designed to help the marine biologists study fish movement in a marine biologists study fish movement in a bounded environment, such as a lake or a bounded environment, such as a lake or a bay.”bay.”
Jamie available the next day.Jamie available the next day. Given instructions for running it and told Given instructions for running it and told
where to find data files.where to find data files.
Chapter 1
Guided Tour
““The biologists think of the environment as The biologists think of the environment as a rectangular grid, with fish moving from a rectangular grid, with fish moving from cell to cell in the grid. Each cell contains cell to cell in the grid. Each cell contains zero or one fish.”zero or one fish.”
Chapter 2
What classes are necessary?
To model To model fishfish swimming in a swimming in a bounded bounded environmentenvironment, the program has , the program has FishFish objects objects and an and an EnvironmentEnvironment object. object.
The purpose of the program is to The purpose of the program is to simulatesimulate fish moving in the environment, so the fish moving in the environment, so the program also has a program also has a SimulationSimulation object. object.
There are other useful, but less important There are other useful, but less important "utility classes.""utility classes."
Chapter 2
One step in the simulation
Fish object id
color
environment
toString
isInEnv
direction
act
location
EnvDisplayobject
showEnvEnvironmentobject
(partial list of methods)
allObjects
objectAt
isEmpty
add
neighborsOf
getNeighbor
getDirection
remove
recordMove
Fish object id
color
environmen
toString
isInEnv
direction
act
locationFish object id
color
environment
toString
isInEnv
direction
act
locationFish object id
color
environment
toString
isInEnv
direction
act
location
Simulationobject step
Chapter 2
What do core classes look like?
Simulation: almost identical to C++ MBCSSimulation: almost identical to C++ MBCS Environment: black box; only look at Environment: black box; only look at class class
documentationdocumentation (think header file!) (think header file!) Fish: Fish:
has color, directionhas color, direction movemove method is a little more method is a little more
complicated, has more helper methodscomplicated, has more helper methods
Chapter 2
move method
Get next location to move to (call Get next location to move to (call nextLocationnextLocation))
If next location is different from this If next location is different from this location,location, move there (call move there (call changeLocationchangeLocation)) change direction (call change direction (call changeDirectionchangeDirection))
Chapter 2
nextLocation method
Get list of empty neighboring locations (call Get list of empty neighboring locations (call emptyNeighborsemptyNeighbors))
Remove location behind fish from listRemove location behind fish from list If there are any empty neighbors left, If there are any empty neighbors left,
randomly choose one; otherwise return randomly choose one; otherwise return current locationcurrent location
Chapter 2
Breeding and Dying
Problem Specification: A fish should ...Problem Specification: A fish should ... have a 1 in 7 chance of breeding,have a 1 in 7 chance of breeding, breed into all empty neighboring locations,breed into all empty neighboring locations, attempt to move when it does not breed,attempt to move when it does not breed, never move backwards, andnever move backwards, and have a 1 in 5 chance of dying after it has have a 1 in 5 chance of dying after it has
bred or moved.bred or moved.
Chapter 3
Breeding and Dying
Pseudo-code for act methodPseudo-code for act method
if this is the 1 in 7 chance of breedingif this is the 1 in 7 chance of breeding
call the call the breedbreed method method
elseelse
call the move methodcall the move method
if this is the 1 in 5 chance of dyingif this is the 1 in 5 chance of dying
call the call the diedie method method
Chapter 3
Breeding and Dying
Test PlanTest Plan Testing random behavior (Chap 2)Testing random behavior (Chap 2) Black-box testingBlack-box testing Code-based testingCode-based testing
Chapter 3
Specialized Fish
Different patterns of movementDifferent patterns of movement Darters (Darters (DarterFishDarterFish)) Slow fish (Slow fish (SlowFishSlowFish))
InheritanceInheritance Dynamic BindingDynamic Binding
Chapter 4
Specialized Fish
DarterFishDarterFish darts two cells forward if darts two cells forward if
possiblepossible or darts one cell forwardor darts one cell forward or reverses direction or reverses direction
(without moving)(without moving)
Chapter 4
DarterFish object id
color
environment
toString
randomColor
isInEnv
direction
act
location
breed
generateChild
move
nextLocation
emptyNeighbors
changeLocation
changeDirection
die
move
nextLocation
generateChild
Specialized Fish
SlowFishSlowFish has only a 1 in 5 chance of moving out has only a 1 in 5 chance of moving out
of current cellof current cell otherwise movement is the same as otherwise movement is the same as FishFish
Chapter 4
Classes for A Exam
Class ImplementationsClass Implementations SimulationSimulation FishFish (as modified in Chapter 3) (as modified in Chapter 3) DarterFishDarterFish SlowFishSlowFish
Class DocumentationClass Documentation A number of utility classesA number of utility classes
Environment Implementations
Multiple environment implementationsMultiple environment implementations Environment InterfaceEnvironment Interface Bounded: 2D array (matrix) -- existingBounded: 2D array (matrix) -- existing Unbounded: ArrayList of Fish -- Pat Unbounded: ArrayList of Fish -- Pat
develops this implementationdevelops this implementation
Chapter 5
Environment Implementations
ExercisesExercises Very large bounded environment (list or Very large bounded environment (list or
sparse matrix)sparse matrix) Sorted list for unbounded environment Sorted list for unbounded environment
with binary searchwith binary search BST for unbounded environmentBST for unbounded environment Hash map for unbounded environmentHash map for unbounded environment
Chapter 5
Classes for AB Exam
Classes and documentation from A ExamClasses and documentation from A Exam Additional Class Interfaces/ImplementationsAdditional Class Interfaces/Implementations
EnvironmentEnvironment BoundedEnvBoundedEnv UnboundedEnvUnboundedEnv
Class DocumentationClass Documentation One new utility classOne new utility class
Key Features
Overall design & core classes are similarOverall design & core classes are similar Discussion of modification/development Discussion of modification/development
allows focus on design and testingallows focus on design and testing Highlights new/different language featuresHighlights new/different language features Highlights new topics in curriculumHighlights new topics in curriculum
Inheritance, dynamic bindingInheritance, dynamic binding InterfacesInterfaces