python plus java in a three course sequence!taming the tiger -- teaching the next generation of...
TRANSCRIPT
-
Python Plus Java in a Three Course Sequence
David RanumBrad Miller
Luther College
-
We’d like them to look like this
-
But many look more like this
-
Want To Avoid This
-
Why do they end up this way?
! Taxonomy of Problems in Teaching Java -- The Java Task Force Difficulties Teaching Java in CS1 and How We Aim to Solve Them! Taming the Tiger -- Teaching the next generation of Java! The Dream of a Common Language: The search for Simplicity and Stability in
Computer ScienceThe original Pascal book by Wirth had 266 Pages, Dietel and Dietel has 1536There are more public methods in the java and javax package heirarchies than there are words in Wirth's book.
! Taming Java for the Classroom! Java is the Canonical Lanuage for teaching introductory programming, but...
! Lots of Papers on help for teaching objects early! BlueJ! ObjectDraw! Karel J Robot
! Java Task Force Libraries
-
Why do they end up this way?
! Taxonomy of Problems in Teaching Java -- The Java Task Force! Taming the Tiger -- Teaching the next generation of Java! The Dream of a Common Language: The search for Simplicity and Stability in
Computer ScienceThe original Pascal book by Wirth had 266 Pages, Dietel and Dietel has 1536There are more public methods in the java and javax package heirarchies than there are words in Wirth's book.
! Taming Java for the Classroom
!Java is the Canonical Lanuage for teaching introductory programming, but...
! Lots of Papers on help for teaching objects early! BlueJ! ObjectDraw! Karel J Robot
! Java Task Force Libraries
-
! Taxonomy of Problems in Teaching Java -- The Java Task Force! Taming the Tiger -- Teaching the next generation of Java! The Dream of a Common Language: The search for Simplicity and Stability in
Computer Science
The original Pascal book by Wirth had 266 Pages, Dietel and Dietel has 1536There are more public methods in the java and javax package heirarchies than there are words in Wirth's book.
! Taming Java for the Classroom! Java is the Canonical Lanuage for teaching introductory programming, but...
! Lots of Papers on help for teaching objects early! BlueJ! ObjectDraw! Karel J Robot
! Java Task Force Libraries
Why do they end up this way?
-
The Java Magic Spell?
Increasingly, people seem to misinterpret complexity as sophistication, which is baffling - the incomprehensible should cause suspicion rather than admiration. (Niklaus Wirth)
-
What Can We Do?
Join the folks trying to fix Java or...
Use a Language that encourages students to focus on problem solving and computer science
As Moti-Ben Ari put it in SIGCSE 2005 Keynote: “Its OK to teach introductory Physics students about levers and pulleys”
-
Its OK to start out on the Green Runs
-
Hello World
public class Hello { public static void main(String[] args) { System.out.println("Hello Java World"); }}
public class Hello { public static void main(String[] args) { System.out.println("Hello Java World"); }}
public class Hello { public static void main(String[] args) { System.out.println("Hello Java World"); }}
public class Hello { public static void main(String[] args) { System.out.println("Hello Java World"); }}
public class Hello { public static void main(String[] args) { System.out.println("Hello Java World"); }}
-
Hello World
>>>print "Hello Python World"Hello Python World
-
Hello World
>(print "Hello Scheme World")“Hello Scheme World”>
-
Our Courses and Goals
Our Students:
Very little programming experience
Bright
Enthusiastic
-
Our Courses and GoalsLearn Computer Science
Problem Solving
Patterns
Techniques
Algorithms
Data Structures
Prepare for Upper Level Courses
-
CS-1
Basic problem solving approaches.
Programming is presented as a notation
Want to encourage not frustrate
Practice Practice Practice
-
CS-2
Students are still beginners!
Classic Algorithms and Data Structures
Problem solving patterns
Analysis
-
CS-3Software Design and Development
2 Parallel TracksJava
ExceptionsInterfacesInner Classes.GUI and Event Driven ProgrammingThreading
Preparing Students for Upper Level CS
-
CS1Case Studies
-
Accumulator
-
Iteration Over a Collection of Objects
-
Nested Loops and Functions
-
Conditionals
-
Classes
-
Python Data Model
Consistency!
1 + 2 == 3
A = 1 + 2
(1).__add__(2) == 3
3A
-
CS2Case Studies
-
Insertion Sort(Pseudocode)
Insertion-Sort(A)for j 2 to length[A] key A[j] i j - 1 while i > 0 and A[i] > key A[i+1] A[i] i i - 1 A[i + 1] key
-
Insertion Sort(Python)
def insertionSort(A): for j in range(1,len(A)): key = A[j] i = j while i>0 and A[i-1]>key: A[i]=A[i-1] i = i-1 A[i]=key
-
Comparing Python to Pseudocode
Insertion-Sort(A)for j 2 to length[A] key A[j] i j - 1 while i > 0 and A[i] > key A[i+1] A[i] i i - 1 A[i + 1] key
def insertionSort(A): for j in range(1,len(A)): key = A[j] i = j while i>0 and A[i-1]>key: A[i]=A[i-1] i = i-1 A[i]=key
-
Running and Testingcray:MICS2005> python -i insertion.py>>> A = [9, 4, 2, 10, 7, 22, 1]>>> insertionSort(A)>>> A[1, 2, 4, 7, 9, 10, 22]>>> B = ['dog', 'cat', 'ape', 'eel']>>> insertionSort(B)>>> B['ape', 'cat', 'dog', 'eel']>>> C = [3.14, 2.78, 9.80, 3.8]>>> insertionSort(C)>>> C[2.78, 3.14, 3.8, 9.8]>>>
-
Sorting Objectsclass student: def __init__(self,lname,fname,gpa): self.fname = fname self.lname = lname self.gpa = gpa def __cmp__(self,other): if self.gpa < other.gpa: return -1 elif self.gpa == other.gpa: return 0 else: return 1
-
Knights Tour
20 21 22 23 24
15 16 17 18 19
10 11 13 14
5 6 7 8 9
0 1 2 3 4
21 23
15 19
12
9
3
5
1
-
Graphclass Graph: def __init__(self): self.vertList = {} self.numVertices = 0 def addVertex(self,key): self.numVertices = self.numVertices + 1 newVertex = Vertex(key) self.vertList[key] = newVertex return newVertex def addEdge(self,f,t,cost=0): if not self.vertList.has_key(f): nv = self.addVertex(f) if not self.vertList.has_key(t): nv = self.addVertex(t) self.vertList[f].addNeighbor(self.vertList[t],cost) def __iter__(self): return self.vertList.itervalues()
for node in graph: print node.color
-
Vertexclass Vertex: def __init__(self,num): self.id = num self.adj = [] self.color = 'white' self.dist = sys.maxint self.pred = None self.disc = 0 self.fin = 0 self.cost = {}
def addNeighbor(self,nbr,cost=0): self.adj.append(nbr) self.cost[nbr] = cost
-
Depth First Searchdef knightTour(n,path,u,limit): u.setColor('gray') path.append(u) if n < limit: nbrList = u.getAdj() i = 0 done = False while i < len(nbrList) and not done: if nbrList[i].getColor() == 'white': done = knightTour(n+1,path,nbrList[i],limit) i = i + 1 if not done: # prepare to backtrack path.remove(u) u.setColor('white') else: done = True return done
orderByAvail(u)
-
Complete Tour
-
CS3Case Studies
-
First Few Weeks
2 weeks Java Basics (Using Collections)
Command Line then IDE
Building Classes
Testing -- jUnit
Interfaces and Inheritance
-
River Crossings
-
Graphpublic class Graph implements Iterable { public Graph() { this.vertList = new HashMap(); this.numVertices = 0; } private HashMap vertList; private int numVertices = 0;
class Graph:
def __init__(self): self.vertList = {} self.numVertices = 0
-
addVertex
def addVertex(self,key): self.numVertices = self.numVertices + 1 newVertex = Vertex(key) self.vertList[key] = newVertex return newVertex
public Vertex addVertex(int key) { this.numVertices = this.numVertices + 1; Vertex newVertex = new Vertex(key); this.vertList.put(key,newVertex); return newVertex; }
-
Iteration
public Iterator iterator() { return vertList.values().iterator(); }
def __iter__(self): return self.vertList.itervalues()
for (Vertex v : g) { System.out.println(node.color);}
-
Event Driven Programming
Java Swing
Java 2D Graphics Programming
Model View Controller Pattern
Listeners and Event Handling
-
Pong
-
What is left?
Swing components
Threading
Simple Network Programming
Source Control
Database Access (JDBC)
XML
-
Next Project jPhoto
-
SummaryPut the focus back on Computer Science and Problem SolvingBy Using Python early we can:
Solve interesting problems that motivateLearn important problem solving patterns
By Moving to Java at the right time we can:Prepare students for successencourage good software development habits
-
[In a programming language] Simple things should be simple and complex things should be
possible. (Alan Kay)