folien1
folien1
A Practical Introduction
using BlueJ
David J. Barnes
Michael Kölling
3.0
Course Contents
• Introduction to object-oriented
programming…
• …with a strong software
engineering foundation…
• …aimed at producing and
maintaining large, high-quality
software systems.
Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling 2
Buzzwords
responsibility-driven
design
inheritance encapsulatio
n
iterators overriding
couplin
cohesion javadoc g
interfac
e
collection mutator methods
classes
polymorphic method
calls
Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling 3
Goals
Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling 5
Course overview (1)
• Objects and classes
• Understanding class definitions
• Object interaction
• Grouping objects
• More sophisticated behavior - libraries
• Well-behaved objects - testing,
maintaining, debugging
• Designing classes
Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling 6
Course overview (2)
• Inheritance
• Polymorphism
• Extendable, flexible class
structures
• Building graphical user interfaces
• Handling errors
• Designing applications
Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling 7
Demo
Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling 8
Fundamental concepts
• object
• class
• method
• parameter
• data type
Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling 9
Objects and classes
• objects
– represent ‘things’ from the real
world, or from some problem
domain (example: “the red car
down there in the car park”)
• classes
– represent all objects of a kind
(example: “car”)
Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling 10
Methods and parameters
• Objects have operations which
can be invoked (Java calls them
methods).
• Methods may have parameters to
pass additional information
needed to execute.
Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling 11
Other observations
• Many instances can be created
from a single class.
• An object has attributes: values
stored in fields.
• The class defines what fields an
object has, but each object stores
its own set of values (the state of
the object).
Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling 12
State
Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling 13
Two circle objects
Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling 14
Source code
• Each class has source code (Java
code) associated with it that
defines its details (fields and
methods).
Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling 15
Return values
• Methods may return a result via a
return value.
Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling 16