0% found this document useful (0 votes)
100 views39 pages

Teaching Oop: A Practical Approach Using Bluej

The document discusses teaching object-oriented programming (OOP) using BlueJ, an environment for teaching Java. It begins with an introduction section asking about the attendees' teaching experience and problems. Next, it discusses analyzing issues with current OOP teaching approaches. The remainder of the document provides suggestions for teaching OOP effectively using BlueJ, including focusing on key concepts like objects and classes before I/O, using larger example projects, and preparing students for real-world tasks like code maintenance.

Uploaded by

rajlove333
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
100 views39 pages

Teaching Oop: A Practical Approach Using Bluej

The document discusses teaching object-oriented programming (OOP) using BlueJ, an environment for teaching Java. It begins with an introduction section asking about the attendees' teaching experience and problems. Next, it discusses analyzing issues with current OOP teaching approaches. The remainder of the document provides suggestions for teaching OOP effectively using BlueJ, including focusing on key concepts like objects and classes before I/O, using larger example projects, and preparing students for real-world tasks like code maintenance.

Uploaded by

rajlove333
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 39

Teaching OOP

A Practical Approach Using BlueJ

David J Barnes Michael Kölling


University of Canterbury University of
Southern Denmark

Teaching OOP - A Practical Approach using BlueJ 1


Introduction
• Who are you?
• What/where do you teach?
• What is your experience with Java
teaching?
• What do you expect from this
workshop?
• What problems do you experience in
your teaching?
Teaching OOP - A Practical Approach using BlueJ 2
Analysis

What is happening with


OOP teaching?

Teaching OOP - A Practical Approach using BlueJ 3


Functions
Data Fields

Conversion: square sqMeters


metres to square
yards for a piece
Methods
of fabric
toSqYards
readSqMeters
displayFabric

getDouble
displayResult
...

Teaching OOP - A Practical Approach using BlueJ 4


Hello World

public class Hello


{
public static void main(String[] args)
{
System.out.println(“Hello, world”);
}
}

Teaching OOP - A Practical Approach using BlueJ 5


Text
public class OldMacDonald {
public static void main(String[] args) {
System.out.println(“Old MacDonald had a farm”);
System.out.println(“E I E I O”);
System.out.println(“and on his farm he had a duck”);
System.out.println(“E I E I O”);
System.out.println(“With a quak quak here”);
System.out.println(“And a quak quak there”);
System.out.println(“Here a quak, there a quak”);
System.out.println(“Everywhere a quak quak”);
System.out.println(“Old MacDonald had a farm”);
System.out.println(“E I E I O”);
} }

1. Write a Java class that prints the second verse


2. Write a Java class that prints the following design...
Teaching OOP - A Practical Approach using BlueJ 6
GUI’s
import java.awt.*;
public class Message2 extends Frame {
Font f;
public Message2() {
f = new Font(“SansSerif”, Font.BOLD, 24);
setBackground(Color.yellow);
setSize(400, 150);
}
public void paint(Graphics g) {
g.setFont(f); g.setColor(Color.blue);
g.drawString(“Welcome to Java”, 100, 100);
}
public static void main(String[] args) {
Message2 m2 = new Message2();
m2.setVisible(true);
}
}
Teaching OOP - A Practical Approach using BlueJ 7
Text input
import java.io.*;

public class Square


{
public static void main(String[] args) throws Exception
{
BufferedReader reader =
new BufferedReader(
new InputStreamReader(System.in));
System.out.println(“Input a number”);
int number = Integer.parseInt(reader.readline());
System.out.println(number + “ squared is “ +
(number * number));
}
}

Teaching OOP - A Practical Approach using BlueJ 8


Why are things like this?
• It has a lot to do with the Pascal
(etc.) heritage.
• Just using a class doesn’t make an OO
program.
• Using an OO language requires a
proper OO approach.

Teaching OOP - A Practical Approach using BlueJ 9


Getting started

How to get over the


first few weeks

Teaching OOP - A Practical Approach using BlueJ 10


Suggestions #1
• Objects first
• Jump start
• Don’t use “main”
• Don’t start with I/O (GUIs, applets, text
I/O)
• Don’t convert old examples
• Teach programming, not a programming
language

Teaching OOP - A Practical Approach using BlueJ 11


Objects first
• Start with key issues:
Objects, classes, methods
• State and behaviour
• Almost universally accepted, but: not
easy

Teaching OOP - A Practical Approach using BlueJ 12


Jump start
• Don’t get students bored with detail
at the start
• Start doing something!
• Experiment with objects before
writing objects.

Teaching OOP - A Practical Approach using BlueJ 13


Don’t use “main”
• What has main got to do with objects? -
Nothing!
public class Hello
{
public static void main(String[] args)
{
System.out.println(“Hello, world”);
}
}

Teaching OOP - A Practical Approach using BlueJ 14


Don’t start with I/O
• I/O is an undesirable distraction from
programming principles
• Text I/O (especially input) is not easy
• Applets are mysterious
• GUIs are complicated
• Custom made libraries…?

Teaching OOP - A Practical Approach using BlueJ 15


Don’t convert
your old examples

• Examples are (or should be)


handpicked to illustrate key points
• Examples from procedural languages
do not illustrate concepts of object
orientation

Teaching OOP - A Practical Approach using BlueJ 16


Teach programming, not a
programming language
• Don’t teach Java, teach OOP!
• Don’t teach OOP, teach
programming!
• Don’t teach programming, teach
problem solving!

Teaching OOP - A Practical Approach using BlueJ 17


Environment again
• need visualisation
• need interaction
• need simplicity
• BlueJ
– successor of Blue system
– supports Java
– written in Java
– free

Teaching OOP - A Practical Approach using BlueJ 18


An Object-Oriented
Environment

• An environment for an object-


oriented language is not the same
as an object-oriented environment

Teaching OOP - A Practical Approach using BlueJ 19


Examples

Shapes and Pictures

Teaching OOP - A Practical Approach using BlueJ 20


Questions / Discussion

Teaching OOP - A Practical Approach using BlueJ 21


Break

Teaching OOP - A Practical Approach using BlueJ 22


Conveying key topics

Teaching OOP - A Practical Approach using BlueJ 23


Examples

Ticket machines &


technical support

Teaching OOP - A Practical Approach using BlueJ 24


Suggestions #2

• Key issues first


• Read code
• Use “large” projects
• Don’t start with a blank screen
• Do sensible things
• Prepare for maintenance

Teaching OOP - A Practical Approach using BlueJ 25


Key issues first

• Choose examples to illustrate key


issues first
• Don’t get stuck in detail
• Avoid completeness trap!

Teaching OOP - A Practical Approach using BlueJ 26


Read code

• Make students read code! (read


before write)
• Show many examples
• Make sure all examples are well
written (and worth reading)

Teaching OOP - A Practical Approach using BlueJ 27


Use “large” projects

• Don’t start with small examples -


they don’t have structure
• Use realistic context
• Concentrate on object interaction

Teaching OOP - A Practical Approach using BlueJ 28


Don’t start with a blank screen

• Starting with a blank screen requires


design (or the example is too trivial)
• Design is hard
• Designing a complete application is
an advanced exercise

Teaching OOP - A Practical Approach using BlueJ 29


Do sensible things

• Choose examples that make sense


• Don’t make students do things that
you wouldn’t do yourself

Teaching OOP - A Practical Approach using BlueJ 30


Prepare for maintenance
• Prepare students for real-life
situations:
– code maintenance
– modification, extension
– documentation
– using class libraries
– reuse

Teaching OOP - A Practical Approach using BlueJ 31


Example

The dark world of Zuul...

Teaching OOP - A Practical Approach using BlueJ 32


Suggestions #3
• Discuss application structure
• Open/closed exercises
• Create ownership
• Apprentice approach

Teaching OOP - A Practical Approach using BlueJ 33


Discuss structure
• OO-modelling
• Relationships of classes
• Coupling and cohesion
• Later: patterns

Teaching OOP - A Practical Approach using BlueJ 34


Open/closed exercises
• Make exercises that are closed so
students know exactly what is
expected of them (and when they are
done), and
• Make exercises that are open so each
student can adapt them to his/her
own level of knowledge, expertise
and ambition
Teaching OOP - A Practical Approach using BlueJ 35
Create ownership
• Create your exercises and
programming projects in such a way
that the students take ownership
• Students then will
– work harder
– have more fun
– learn much, much more...

Teaching OOP - A Practical Approach using BlueJ 36


Apprentice approach
• Let students observe what you are
doing
• See teacher in action
• Learn by imitation

Teaching OOP - A Practical Approach using BlueJ 37


Reflection / Discussion

Teaching OOP - A Practical Approach using BlueJ 38


References
The material from this workshop will be
available on the web:
www.mip.sdu.dk/~mik/bluej-workshop

David J Barnes, Michael Kölling


Objects First with Java -
A Practical Introduction using BlueJ

http://www.bluej.org
Contact: David Barnes (djb@kent.ac.uk)
Michael Kölling (mik@mip.sdu.dk)
Teaching OOP - A Practical Approach using BlueJ 39

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy