0% found this document useful (0 votes)
27 views

Lecture 01b Objects First

This document provides an overview of the course "Objects First with Java" taught at KTH Royal Institute of Technology in Stockholm, Sweden. The course covers fundamental object-oriented programming concepts using Java, with a focus on designing well-structured and tested software systems. Topics include objects, classes, methods, parameters, and designing class structures. Students will implement a small software project in Java to practice these concepts.

Uploaded by

Amitesh Saha
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Lecture 01b Objects First

This document provides an overview of the course "Objects First with Java" taught at KTH Royal Institute of Technology in Stockholm, Sweden. The course covers fundamental object-oriented programming concepts using Java, with a focus on designing well-structured and tested software systems. Topics include objects, classes, methods, parameters, and designing class structures. Students will implement a small software project in Java to practice these concepts.

Uploaded by

Amitesh Saha
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

KTH ROYAL INSTITUTE

OF TECHNOLOGY
Stockholm
Sweden

Objects First with Java


A Practical Introduction using
BlueJ

Ric Glassey
[email protected]
Course Contents

• Introduction to object-oriented programming…


• …with a strong software engineering
foundation…
• …aimed at producing and maintaining large,
high-quality software systems.

2
Buzzwords
inheritance
responsibility
overriding
iterators -driven design
javadoc encapsulation
cohesion interface
coupling
collection classes mutator methods
polymorphic method calls
3
Goals

• Sound knowledge of programming principles


• Sound knowledge of object-orientation
• Able to critically assess the quality of a (small)
software system
• Able to implement a small software system in
Java

4
Book
Objects First with Java
A Practical Introduction using BlueJ
David J. Barnes & Michael Kölling

5th edition (ebook/pdf available as part of course)


Pearson Education
ISBN 0-13-249266-0
978 0-13-249266-9

5
Course overview (1)
• Objects and classes
• Understanding class definitions
• Object interaction
• Grouping objects
• More sophisticated behaviour using libraries
• Designing classes
• Well-behaved objects - testing, maintaining, debugging

6
Demo: Figures Project

7
Fundamental concepts

• Object
• Class
• Method
• Parameter
• Data type

8
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”)

9
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.

10
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).

11
State

12
Two circle objects

13
Demo: Figures Project

14
Source code

• Each class has source code (Java code)


associated with it that defines its details (fields
and methods).

15
Demo: Lab Classes

16
Return values

• All the methods in the figures project have void


return types; but …
• … methods may return a result via a return value.
• Such methods have a non-void return type.
• More on this in the next lecture.

17
Concept Review

• Object: Java objects model things from a


problem domain

• Class: Objects are created from classes

• Instance: A single object of a particular class. You


can create multiple instances from a single class

18
*Concept Review*

• Method: A way to communicate with objects and


make them do some task

• Parameter: Provides extra information to a method

• Signature: The header of a method explains how a


method can be used, and what it returns

19
*Concept Review*

• Method Calling: Objects calling methods of other


objects to communicate

• Source Code: The written program. Defines the


structure and behaviour for a class.

• State: Objects store state. It is the contents of the


fields, and can change over the lifecycle of an object

20
*Required Reading*

• Chapter One
• Objects First with Java, 5th/6th Edition

21

You might also like