oop in introductory cs

17
OOP in Introductory CS Stephen Wong and “Zung” Nguyen Rice University Better students though abstraction

Upload: malo

Post on 06-Jan-2016

27 views

Category:

Documents


0 download

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 Presentation

TRANSCRIPT

Page 1: OOP in Introductory CS

OOP in Introductory CS

Stephen Wong and “Zung” Nguyen

Rice University

Better students though abstraction

Page 2: OOP in Introductory CS

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

Page 3: OOP in Introductory CS

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.

Page 4: OOP in Introductory CS

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

Page 5: OOP in Introductory CS

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!

Page 6: OOP in Introductory CS

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

Page 7: OOP in Introductory 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

Page 8: OOP in Introductory CS

The RoadConcrete Objects

Abstract Objects & Behaviors

Polymorphism

Strategies

Encapsulation

Recursion

VisitorsState PatternAbstract Construction

Factories

Decoupling

AdaptersDecorators

Lambda Calculus

Anonymous classes

Composition

Delegation

Page 9: OOP in Introductory CS

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

Page 10: OOP in Introductory CS

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

Page 11: OOP in Introductory CS

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

Page 12: OOP in Introductory CS

The Role of Design Patterns

DesignPatterns

Languageof Abstraction

TangibleAbstraction

Focus onAbstraction

Page 13: OOP in Introductory CS

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

Page 14: OOP in Introductory CS

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

Page 15: OOP in Introductory CS

Plugging into the StudentsWhat is it that

really interests our students?

Games

AIRoboti

cs

Graphics

“Real Programs”

Networking

Page 16: OOP in Introductory CS

Getting the Students to Plug In

Grap

hical In

terfaces

Sim

plic

ity +

Pow

er

Unim

agined capabilities

Cutting edge technologyFun, fun, fun!!!

Page 17: OOP in Introductory CS

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