48
Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan http://www.cs.duke.edu/~ola

Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Embed Size (px)

Citation preview

Page 1: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 1

Where are we going ?Where have we been? Twenty years of Computer Science and Programming

Owen Astrachanhttp://www.cs.duke.edu/~ola

Page 2: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 2

Programming != Computer Science What is the nature of intelligence? How can one

predict the performance of a complex system? What is the nature of human cognition? Does the natural world 'compute'?

It is the interplay between such fundamental challenges and the human condition that makes computer science so interesting. The results from even the most esoteric computer science research programs often have widespread practical impact. Computer security depends upon the innovations in mathematics. Your Google search for a friend depends on state-of-the-art distributed computing systems, algorithms, and artificial intelligence.

http://www.post-gazette.com/pg/pp/04186/341012.stm

Page 3: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 3

Twenty years in different fields “If I got 100 on the final in your first year

course(s) in 1984, with complete mastery of the material, and I didn’t forget anything (I spend 20 years in a cryogenic chamber), how would I do on the final today?”

Biology

Physics

Mathematics

Computer Science

Page 4: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 4

AP Computer Science in 1984 64K memory, 128K

with "extended memory"

8-bit, 1 Mhz 6502 processor

5Mb hard drive: $3500 UCSD Pascal: >$100 Owen's machine:

$3000 $677.80 in 1984 has

$1200 "purchase power" in 2003

http://eh.net/hmit/ppowerusd/

Page 5: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 5

What has changed in 20 years? Machines

Characteristics Availability

Internet Characteristics Availability

Students Comfort with technology Expectations

Page 6: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 6

What has changed in 20 years? What do we teach today that we didn’t teach

before?

What did we teach 20 years ago that we don’t today?

What does this say about Computer Science?

Page 7: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 7

1984, AP Computer Science, Q1 Write a program to read eight integers

from the terminal, display them in reverse order, and display the number of negative integers read. For example, given the input:

-4 3 -2 1 -18 -20 5 -7

The program should produce the output:

-7 5 -20 -18 1 -2 3 -45 of the integers are negative

Page 8: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 8

What concepts does this test? Reading from standard input, terminal

In today’s programming we don’t do this?

What is special about the number eight? Why eight? Did the question writers expect an array-based

solution?

Loops, counter, conditional Standard and still part of the course today?

Other concepts tested?

Page 9: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 9

1985, AP Computer Science, Q2

Write a procedure Compact that eliminates all elements with value 0 from its argument, a list. Compact leaves the order of the other elements unchanged. For example, if list is

(0,9,7,0,0,23,4,0) When the procedure is called, it should be (9,7,23,4) After the procedure executes. All local

variables should be scalar.

(declaration for Pascal record with array and count)

Page 10: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 10

Concepts and Solutions Why the restriction to use only scalar

variables? Force an expected solution? Punish students?

What does the expected solution look like? One loop with nested, shifting loop? One loop with non-zeros “moved to front”? Auxiliary array, store non-zeros, then copy back?

What does this look like today? (to appear)

Page 11: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 11

1985, AP Computer Science, Q5 An image can be represented as a grid

of black and white cells. Two cells in an image are part of the same object if each is black and there is a sequence of moves from one cell to the other, where each move is either horizontal or vertical to an adjacent black cell. For example, the diagram below represents an image that contains two objects, one of them consisting of a single cell.

Page 12: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 12

1985, AP Computer Science, Q5 Write the procedure

procedure EraseObject(var image:ImageType; row, col:integer);

Such that all cells in the same object as image[row,col] are set to White; otherwise image is unchanged. Your solution should have no more than 15 statements, and its execution time should be linear with respect to the number of cells in the object.

Page 13: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 13

2004, AP Computer Science A1 I can’t cut/paste from the online PDF

document without a password, why? Who owns the copyright? What about face-to-face teaching purposes? What is duration of copyright?

How is the question similar to 1984 and 1985 questions? How is it different? Has more than just the language changed? Is a change in language warranted? How often do we change? What do we change?

Page 14: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 14

Who is Alan Perlis? It is easier to write an

incorrect program than to understand a correct one

Simplicity does not precede complexity, but follows it

If you have a procedure with ten parameters you probably missed some

If a listener nods his head when you're explaining your program, wake him up

Programming is an unnatural act

Won first Turing awardhttp://www.cs.yale.edu/homes/perlis-alan/quotes.html

Page 15: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 15

Don’t know much about history

Page 16: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 16

What teachers are memorable?

The good, the bad, and the …?

Page 17: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 17

John Kemeny If you have a large number of unrelated ideas, you have to get quite a distance away from them to get a view of all of them, and this is the role of abstraction. If you look at each too closely you see too many details. If you get far away things may appear simpler because you can only see the large, broad outlines; you do not get lost in petty details.

Page 18: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 18

Great Teachers

QuickTime™ and aH.263 decompressor

are needed to see this picture.

Page 19: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 19

A Survey of Introductory Courses

The principal course goal is for the students to become proficient in a single programming language.

To achieve the course's objective each student must write about 300 total lines of code. This coding represents about 6 different programming assignments. At least one assignment requires writing over 75 lines of code. We estimate that a student averages over 10 hours per week on the course even though the usual turnaround time is less than ½ hour.

van Dam et al, 1973

Page 20: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 20

Then and NowOuchless I/O Bailey, SIGCSE 1972

All of the Fortran statements were to be introduced as the need arose within the context of a problem-solving situation—that is, a here-is-what-we-want-how-can-we-do-it approach…the overall objective of the course was to make the instruction as interesting and informative as possible.

It is remarkable that the majority of students can indeed handle fairly complex I/O by the end of the first six lessons, even though they have not actually been formally taught how to do it.

Page 21: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 21

Now and ThenJava IO and Testing Made Simple, Proulx and Rasala, SIGCSE 2004

We believe that the combination of the well-designed tools with well-designed abstractions presented here provide a solid foundation for introducing input processing to novice programmers.

In addition to making the input from the user an integral part of student's programs, students learn from seeing and using abstractions that provide tangible and significant benefits.

Page 22: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 22

Gries on Teaching Programming

“Suppose you attend a course in cabinet making. The instructor briefly shows you a saw, a plane, a hammer, and a few other tools, letting you use each one for a few minutes. He next shows you a beautifully-finished cabinet. Finally, he tells you to design and build your own cabinet and bring him the finished product in a few weeks. You would think he was crazy!”

How do you hold a saw? How do you cut? How do you use Eclipse? How do you develop an invariant? How do you write code?

Page 23: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 23

Putting it all together …

…we conclude that students are not given sufficient instruction in how to "put the pieces together." Focusing explicitly on specific strategies for carrying out the coordination and integration of the goals and plans that underlie program code may help to reverse this trend.

Sporher and Soloway, Novice mistakes: Are the folks wisdoms correct? Studying

the Novice Programmer, 1989

Page 24: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 24

The Art of Changing the Brain

Enriching the Practice of Teaching by Exploring the Biology of Learning

James Zull

Page 25: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 25

Learning theory/Brain theory

ConcreteExperience

ReflectiveObservatio

n

AbstractHypothesis

ActiveTesting

Page 26: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 26

What do we show and tell students? “I see”

“I understand” “I get the picture” and “I see the big

picture” “I understand”

Teacher, from the old English techen, “to show”

Explain the idea, the algorithm, the pattern Show me the code!!

Page 27: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 27

Changing Data into Knowledge

We provide an unjust education if we do not give every student the maximum opportunity for learning. Depending on their natural abilities, imbalance in education deprives some students of learning more than others. Those who are naturally more creative, or have better memories, or are more reflective, or are more active have different opportunities if we do not provide balance. That is unjust.

Page 28: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 28

Changing Data into Knowledge

Information that enters the brain from outside is, by definition, in the past for that brain.

Do teachers create opportunities, even make demands, for students to transform the information which came from their past into their future?

Page 29: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 29

Changing Data into Knowledge

As teachers we are on the outside, but we have great influence by the way we manipulate, mold, and enrich the information our students need. For balance, we must give equal thought to how students take ownership of that information. How it is transformed from “ours” to “theirs”? How does the learner move from receiver to producer?

Page 30: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 30

Changing Data into Knowledge

At the beginning, through sensory input, learners are dependent on some outside authority to inform them. This can be the teacher, or t can be a book, or today it often is the Internet. The source is not important, but for learning to happen, learners must continually take in new sensory input from outside themselves. The question is, when do they take power themselves? How do teachers facilitate that? Or might they even resist it.

Page 31: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 31

Changing the Brain

Feelings affect learning What's the amygdala? ".. Emotions tend to overpower cognition,

rather than the reverse"

Some sensory signals get to the amygdala before we are even aware of them, signals come from concrete experiences When we want to help someone learn, we

should be aware that our learner will be quickly and subconsciously monitoring the situation through her amygdala. This isn't something she decides to do. It just happens.

Page 32: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 32

Teaching as … English is not history and

history is not science and science is not art and art is not music, and art and music are minor subjects and English, history and science major subjects, and a subject is something you 'take' and when you have taken it, you have 'had' it, and if you have 'had' it, you are immune and need not take it again." (The Vaccination Theory of Education?)

Page 33: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 33

Teaching as a Subversive Activity

"The inquiry method is not designed to do better what older environments try to do. It works you over in entirely different ways. It activates different senses, attitudes, and perceptions; it generates a different, bolder, and more potent kind of intelligence. Thus, it will cause teachers and their tests, and their grading systems, and their curriculum to change. It will cause college admissions requirements to change. It will cause everything to change."

italics mine

Page 34: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 34

Teaching as a Subversive Activity

“As soon as students realize that their lessons are about their meanings, then the entire psychological context of schools is different. Learning is no longer a contest between them and something outside of them, whether the problem be a poem, a historical conclusion, a scientific theory, or anything else. … There are few occasions for feelings of inadequacy, few threats to their sense of dignity, less reason to resist changing perspectives. In short, the meaning-maker metaphor puts the student at the center of the learning process. … And this is the basis of the process of learning how to learn…”

Page 35: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 35

Fundamental Laws First do no harm

• Hippocratic Oath A robot may not injure a human being, or,

through inaction, allow a human being to come to harm

• First law of Robots (Asimov) You know you have achieved perfection in

design, not when you have nothing more to add, but when you have nothing more to take away.

• Saint-Exupery

Do the simplest thing that could possibly work• First Design Principle of Extreme Programming

Page 36: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 36

Tension in Teaching OO Concepts Left to their own devices and designs, students

cannot write correct and well-designed programs Solution: Frameworks, Apprentice-Learning, add to

existing code, implement a design-provided Solution: Good design comes from experience,

experience comes from bad design

Students relish creating programs from scratch Is it ok to use an API from JDK 1.x, 2.x, 5.x, from the

book, from the course, from the assignment? There’s no time to create interesting programs from

scratch

OO design patterns and skills don’t necessarily scale down

Page 37: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 37

Alan Kay: Turing Award 2004"Simple things should be simple.

Complex things should be possible".

"The best way to predict the future is to invent it"

Kay, because of his experience with children, his love of education, his diverse interests, and his genius, recognized that users can and should interact with a computer in different ways and should not be limited to only text. He was among the first to represent objects in a computer as pictures -- a metaphor that he further extended by developing the concept of object orientation. He is, clearly, one of the fathers of the modern PC

http://ei.cs.vt.edu/~history/GASCH.KAY.HTML

Page 38: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 38

MVC: Model, View, Controller A model is the state and brains of a system

In a game it's all the pieces and where they are In a spreadsheet it's the data and the formulae

The view is how we look at the model Spread sheet has graphs, charts, cells, text, … Game has board, number of opponents, hit-

points, …

When the model changes, the views reflect the changes The model tells the views how/if it has changed Model sends information to views OR View asks model for information

Page 39: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 39

Interfaces, Inheritance, Design What’s an interface?

Different from base class? How? Why use an interface?

When should we use an abstract class? What makes a class abstract? How do we know what to make abstract?

What are benefits of interfaces? What is Comparable? What is a Stack (in java.util and in APCS?)

Page 40: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 40

MVC: interfaces and inheritance A model might have multiple views

Tell all the views "I've changed" Who manages the views? This requires state: store

views Why can't we keep this state in an interface?

See IModel and AbstractModel One specifies behavior, the other provides default Don’t rewrite code if we don't have to, maintaining

views will be the same for all models

See IView and SimpleView No default/shared view state/behavior: text and GUI

Page 41: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 41

Playing Jotto Given a view, how do we create a model?

Students know how to interact with the view from previous assignments

Students understand how view calls model and vice-versa

What can we do in the model Keep track of guessed words Show the user the state of the game Ultimately have user guess computer’s word?

Page 42: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 42

Making the JottoModel The method process receives the user’s string

Use case: if not in dictionary … Use case: if word found … Use case: if number of guesses exceeds limits … Use case: if word already guessed …

Each time user enters string, the process method is called So, the model exists, but process called over-and-

over, implications for storing values? Where does information on EASY, MEDIUM, HARD

live? How do we refactor?

Page 43: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 43

What is random? What does java.util.Random guarantee?

What about nextInt()? What about really, really random?

What is java.security.SecureRandom How can we use this in a program? Why would we want to use it in a program?

What about random.org What is pseudo-random and do we care? What’s the stuff about the European Union?

Page 44: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 44

How do we test randomness? What examples should we use to test randomness

What about different random number generators? Something simple to instill confidence? Something complex if we knew what we were doing?

Can we fake the source of data from random.org? How is this source certified? Is this a curiousity or a useful tool?

What about Las Vegas, slot machines, and poker? What about electronic voting?

Page 45: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 45

What’s a Playing Card? What does the Icard interface specify? public interface ICard extends Comparable

}public int getRank();public int getSuit();

public static final int CLUBS = 3;public static final int DIAMONDS = 2;public static final int HEARTS = 1;public static final int SPADES = 0;

{

Page 46: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 46

What’s a Deck? What behavior does a Deck have?

initialize

How do we test a Deck Where do the cards come from? What kind of card do we get? What makes a Deck a “good” deck? How can we automate Deck testing?

Page 47: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 47

How do we program video poker? What’s the model for video poker?

What does the machine keep track of? How does video poker work in your state? What happens in North Carolina?

What’s the view for video poker? How do we see a card? Where do we get card images?

How do the model and the view interact? Similar to other MVC programs

Page 48: Stonehill, October 2004 1 Where are we going ? Where have we been? Twenty years of Computer Science and Programming Owen Astrachan ola

Stonehill, October 2004 48

What’s in a Video Slot Machine? What drives a slot machine?

What is a “loose” machine? A “tight” machine? What happens when user “pulls the lever”?

Random numbers generated, source for numbers? Numbers are mapped to virtual reel stops (e.g.,

0--63) Virtual reel stops correspond to actual reel

stops• Suppose 0-19 map to 0, 20-39 map to 1, 40-

59 map to 2, and 60-63 map to 3 This is how machines actualy work!