Java by Bruce Heckel Part 1
Java by Bruce Heckel Part 1
Java by Bruce Heckel Part 1
Light
on()
off()
brighten()
dim()
Characteristics + Behavior
Object
Request
lt.on();
page 1
Class User
(Client Programmer)
Class Creator
Type name
Car
Interface
start();
drive();
etc...
Implementation
Engine
Wheel[4]
Door[2]
etc...
5
Shape
draw()
erase()
Circle
draw()
erase()
Square
draw()
erase()
Line
draw()
erase()
page 2
Polymorphism
One piece of code ...
... works with all these objects!
a Circle
draw()
erase()
Shape
a Square
a Line
An Amazing Trick
void doStuff(Shape s) {
s.erase();
// ...
s.draw();
}
Circle c = new Circle();
Triangle t = new Triangle();
Line l = new Line();
doStuff(c); // "Dynamic binding"
doStuff(t);
doStuff(l);
8
Object-Oriented programs
object
me
ss
ag
e
object
message
object
me
ss
ag
page 3
OOP Design
Most designs can be simplified by adding
another level of indirection/abstraction
Things
that
Stay the
Same
Things
that
Change
In the design
At compile-time
At run-time
In the environment
Etc.
11
page 4
Multithreading
For responsiveness
For running multiple tasks (animation &
networks)
Well cover this in Chapter 14
14
Persistence
Objects that live between program
invocations
Convenient, Java has object serialization
built in, supports lightweight
persistence. Primarily added to support
remote method invocation (RMI) across
networks.
JDBC could be thought of as
another form of persistence
JavaSpaces, further
evolution
15
page 5
17
Summary
Java
Procedural
Data
Function
Function
Data
Message
or
Request
Function
Function
Function
Member
function
or
method
Function
Encapsulation (?)
18
page 6
Click Here
to Return to Home Page
19
page 7