oop in introductory cs
DESCRIPTION
OOP in Introductory CS. Better students though abstraction. Stephen Wong and “Zung” Nguyen Rice University. A Struggling Pedagogy. Java Power Tools Northeastern Univ. Karel the Robot Univ. Waterloo and others. Graphics-based OO Wiliams College. OO Lab Project Univ. Wisconsin. - PowerPoint PPT PresentationTRANSCRIPT
OOP in Introductory CS
Stephen Wong and “Zung” Nguyen
Rice University
Better students though abstraction
A Struggling Pedagogy
OO OverkillDuke Univ.
Java Power ToolsNortheastern Univ.
OO Lab ProjectUniv. Wisconsin
Etc., etc.
Polymorphic Panelists
Graphics-based OOWiliams College
Karel the RobotUniv. Waterloo and others
OOPSLA OO Workshop
Old Intro CS at OberlinCS 1 & 2 in Java
Was procedural + a bit of OOP
3rd semester in Scheme Problems
Students knew syntax but not programming.A big conceptual jump into SchemeNo experience with design.No large scale project experience.Non-inspiring course.
What can students do?
Koch Curves
Frogger, pretty
Swarming/Flocking Simulation
Movie loop, cute
Multiple controllable threads
Puzzle Game
Frogger, extended
Movie loop, techno
Ballworld Animation
Frogger, nuts
Remote, distributed agents
Client-server game
OO First?
Myth: OO is an advanced concept.Students intrinsically
understand polymorphism
Students intrinsically understand object behaviors.
Students intrinsically understand how objects interact
Leverage what the students already understand!
Definitely!
It’s not that easy…
Concrete objects Abstract objects
Concrete behaviors Abstract behaviors
Learning abstract thinking is not easy.
Abstraction the key to understanding CS
What is a Design Pattern?An abstracted solution to a class of
problems.Describes relationships between objectsDescribes when and how those relationships
can used.
But why do they work?
Design patterns are expressions
of fundamental CS principles
The RoadConcrete Objects
Abstract Objects & Behaviors
Polymorphism
Strategies
Encapsulation
Recursion
VisitorsState PatternAbstract Construction
Factories
Decoupling
AdaptersDecorators
Lambda Calculus
Anonymous classes
Composition
Delegation
AElement+accept(AVisitor v)+other methods…
ElementA+accept(AVisitor v)
ElementB+accept(AVisitor v)
Example: Visitor Pattern
Concrete Elements
Abstractly Equivalent
v.methodA(this); v.methodB(this);
One method
per element
AVisitor+methodA(AElement e)+methodB(AElement e)
Visitor1+methodA(AElement e)+methodB(AElement e)
Visitor2+methodA(AElement e)+methodB(AElement e)
Concrete Visitors
Abstractly Equivalent
Abstract, Invariant Data Structure
Variant, Decoupled Algorithms
Visitors Teach…Decoupling of variant and invariantPolymorphic dispatchingEncapsulation of a processAbstract equivalence If elements are empty vs. non-empty lists
Visitor methods: base and inductive cases.Declarative style programming
Design Patterns are tools to teach CS concepts
Design Patterns as Embodiments of Abstract Concepts
Abstract behavior
Decoupled behavior
Recursion
Abstract construction
Strategy
State
Visitor
Decorator
Variant vs. Invariant
Encapsulation
Delegation
Factory
Composite
MVC
Adapter
The Role of Design Patterns
DesignPatterns
Languageof Abstraction
TangibleAbstraction
Focus onAbstraction
Example: Koch Curve LabKoch-Point a,b+grow(AFactory f)+paint()
DrawOneStategrow(AFactory f)paint()
DrawManyStategrow(AFactory f)paint()
CurveFactory+makeOne()+makeMany()
SnowflakeFactory+makeOne()+makeMany()
AKochStategrow(AFactory f)paint()
1
LRStructexecute(IAlgo algo)
1
*
GrowAlgonullCase()nonNullCase()
PaintAlgonullCase()nonNullCase()
1 1
AFactory+makeOne()+makeMany()
uses
A curve between 2 points State Design Pattern
Concrete States
Base case
Ind
uctive case
Com
posite P
attern
LRStruct Visitor Pattern Algorithms
Base case construction
Factory Design Pattern
Inductive case construction
Base caseInductive case
Concrete Factories
Only one line of code that
actually grows/paints!
Run program
Technology an Integral Part of the Pedagogy
UML Diagramming Tool
Integrated DevelopmentEnvironment
Focus on design,
not syntax
Focus on the objects/classes, not the implementation
Focus on the problem,
not API
Focus on the Abstraction!!
Plugging into the StudentsWhat is it that
really interests our students?
Games
AIRoboti
cs
Graphics
“Real Programs”
Networking
Getting the Students to Plug In
Grap
hical In
terfaces
Sim
plic
ity +
Pow
er
Unim
agined capabilities
Cutting edge technologyFun, fun, fun!!!
Synergy
Focus on AbstractionDesign Patterns
Development Tools
Leveraged Student Experiences
Rich Lab Experiences
Cohesive Pedagogical Path
Fundamental CS Principles
Fun, inspiring results
LearningAbstractThinking.
The best students
ever.
http://www.exciton.cs.rice.edu/cs150http://www.exciton.cs.rice.edu/cs151
Demos