Teaching Java - PowerPoint PPT Presentation

About This Presentation
Title:

Teaching Java

Description:

Using abstractions to make concepts concrete. SIGCSE Education Award lecture, 2005. ... abstraction (modeling) design. 4. Principle 3. Present concepts at the ... – PowerPoint PPT presentation

Number of Views:26
Avg rating:3.0/5.0
Slides: 24
Provided by: csCor
Category:

less

Transcript and Presenter's Notes

Title: Teaching Java


1
Teaching Java with OO first
David Gries Computer Science Cornell
University Ithaca, NY 14850
2
Principle 1. Reveal the programming process, in
order to ease and promote the learning of
programming. Principle 2. Teach skills, and not
just knowledge, in order to promote the learning
of programming.
3
Principle 1. Reveal the programming process, in
order to ease and promote the learning of
programming. Principle 2. Teach skills, and not
just knowledge, in order to promote the learning
of programming.
Most texts teach programs, not programming. They
focus largely on knowledge, not skill. CS people
in general put little emphasis on the programming
process.
Every lecture should deal in some way with the
skill of program development.
4
Principle 3. Present concepts at the appropriate
level of abstraction.
5
Principle 3. Present concepts at the appropriate
level of abstraction.
6
Principle 3. Present concepts at the appropriate
level of abstraction.
7
Principle 3. Present concepts at the appropriate
level of abstraction.
The computer is not the appropriate level of
abstraction to describe variables, assignment,
and other programming language concepts!
"An object has its own unique identity, which
distinguishes it from all other objects in the
computers memory An objects identity is
handled behind the scenes by the Java virtual
machine and should not be confused with the
variables that might refer to that object."
8
Algol 60 language definition CACM, Jan
1963. "The purpose of the algorithmic language is
to describe computational processes. "
"A variable is a designation given to a single
value. Assignment statements serve for assigning
the value of an expression to variable . The
process will be understood to take place in three
steps 4.2.3.1. Subscript expressions occurring
in the left part variable are evaluated in
sequence from left to right. 4.2.3.2. The
expression of the statement is evaluated. 4.2.3.3.
The value of the expression is assigned to the
left part variable, with any subscript
expressions having values as evaluated in step
4.2.3.1."
9
Principle 4. Order the material so as to minimize
the introduction of terms or topics without
explanation as much as possible, define a term
when you introduce it.
Almost every line of a Java program deals with a
class or an object!!
10
Principle 5. Use unambiguous, clear, precise,
terminology.
Don't use pointer and reference. Novices do not
know what they mean.
Use inheritance properly.Java version private
components are not inherited.Better version all
components are inherited from the superclass,
because they all appear in each object of the
subclass.
Use parameter argument, not formal parameter
actual parameter.
These sentences from texts completely confuse the
issue The semantics of an assignment for
primitive types and for objects is
different. When an object is passed to a
method, we are actually passing a reference to
that object.
11
Facilitating the teaching of OO first
  • An IDE that does not require a Java application
    e.g. DrJava or BlueJ.
  • An appropriate notational machine model of
    execution.
  • Constructive alignment Course outcomes,
    teaching/learning activities, and assessment
    methods are all aligned.
  • Biweekly quizzes Students are told exactly what
    will be on the quiz and are expected to get
    100/100 on them.
  • Closed labs.
  • One-on-one sessions.

12
Notational machine
  • Two aspects
  • Structural/organizational ØØ
  • Procedural algorithms, conditionals, loops,
    arrays, etc.
  • When teaching Java, principle 3 mandates teaching
    OO first.
  • We provide a model for classes and objects that
  • Can be taught after the students know only about
    (a) types and expressions, (b) variables, (c) the
    declaration lttypegt ltvariablegt and (d) the
    assignment statement.
  • Does not mention the computer.
  • Is in terms of a concept with which students are
    already familiar.

13
A class is a file drawer. It contains manila
folders, all having the same kind of information
Names that go on tabs of manila folder form a new
type. Importance cannot be overestimated. Allows
us to eliminate terminology like pointers and
references.
manila folder an object or instance of the class
14
A class is a file drawer. Its manila folder
contain the same fields and instructions (methods)
Instructions in folder for people to carry out
methods Function returns a valueProcedure does
something, does not return a value
15
pat
C1
variable contains the name of the folder
getName() Deposit(double)
pat.getName() function call. Its value
is B. Clinton pat.deposit(250.0)
procedure call. Subtract 250.0 from field
owes.
16
m
?
C2
variable contains the name of the folder
new Patient() An expression create a
new folder (put it in file-drawer
Patient) and give as the value of the
expression the name of the folder. m new
Patient() A statement evaluate new
Patient() and store its value (the name
of the new folder) in variable m.
C2
17
j
a0
variable contains the name of the folder
A manila folder (object) of class
javax.swing.JFrame() Maintains a window on
your monitor, with methods(instructions) for
manipulating it
18
j
a0
a0
javax.swing.JFrame
show() hide() setTitle(String)
getTitle() getHeight()
getWidth() setSize(int, int) getX() getY()
setLocation(int, int) isResizable()
setResizable(boolean)
variable contains the name of the folder
Drawing a folder (object) for a subclass.
Students learn how to draw such folders. It is
important for later understanding that they know
that the complete method resides in the folder.
19
j
a0
a1
a1
k
Assignment is seen to follow the normal rules for
an assignment To execute j k evaluate
expression k (gives the value a1) and store its
value in j.
20
Model helps, right from the beginning
  • Students understand what an object is, right from
    the beginning. The explanation is not in terms of
    a computer.
  • The pictorial nature of the model is important.
    The name on the tab is most important. Our
    students learn to draw objects for subclasses,
    and they use it later to learn various concepts
    (inheritance, overriding, the inside-out rule for
    determining what declaration a method call or
    variable refers to.
  • Pointer and reference are not used.
  • UML diagrams are inadequate because they do not
    have the equivalent of the name on the tab of an
    object. Although it would be easy to extend UML
    diagrams for objects to include it.

21
i
Inside-out rule To determine to which variable
declaration a variable reference refers, search
in the current scope, the enclosing scope, its
enclosing scope, etc. until it is found. (Similar
rule for method declarations and calls.)

w
sv m()
5
SC's file drawer
Inside-out rule used in just about every
programming language and in predicate logic
22
Closed labs, after lectures 1, 3, 5, , give
practice with concepts. Lecture 1. Types,
expressions, variables, assignments Lecture 2.
Objects Lecture 3. Class def. Subclass of JFrame
with 2 methods Lecture 4. Fields, getter/setter
methods. Junit testing Lecture 5. Class
hierarchy. Static variables Lecture 6. Methods
method bodies local variables
if-statement Lecture 7. Super-this inside-out
rule. Stepwise refinement Lecture 8. Overriding
constructors in subclasses Stepwise
refinement Lecture 9 and 10. Recursion Lecture
11. Casting about instanceof Lecture 12. Loops
23
David and Paul Gries. A Multimedia Introduction
to Programming Using Java. Springer Verlag, NY
2005. Comes with a CS that has 250-odd 2-5 minute
lectures with synched animation. Here, we can
really concentrate on program development.
Webpage for last Spring's course. http//www.cs.c
ornell.edu/courses/cs100j/2007sp/ You can get
slides of lectures and labs, assignments, etc.
Write a Comment
User Comments (0)
About PowerShow.com