![]() |
Last updated: 23/8/02; 9:06:16 PM |
![]() |
|
The Desktop Fishbowl A Java Learning Environment
Update: Like all good ideas, it seems someone else has had this one first. Check out BlueJ for an example of pretty much exactly what I was talking about.
In “Rethinking the Java Curriculum: Goodbye, Hello World!”, Daniel Steinberg talks about how non-OO current introductions to the highly object-oriented Java language are, and challenges us to come up with an alternative. I've taught a number of Introduction to Java courses, and I've long thought there must be a better way. Here's mine.
The way we teach Java to beginning programmers at the moment often does more harm than good. In a nutshell, the problems lie in two places—the need to produce fully running programs, and the consequent far-too-early introduction of the GUI.
Procedural and functional languages, you learned by starting with simple, command-line programs that calculated your biorhythms, your ideal weight, or how many cents you earn per minute. If you take the same approach with Java, you end up teaching all new Java programmers how to code procedurally. You then have to repair the damage you've caused, and shunt them painfully into the world of objects.
Java's command-line capabilities are also pretty dismal, so almost immediately, students are asked to write applets or stand-alone GUI components. GUI programming is difficult, and involves understanding a lot of concepts that students aren't even remotely comfortable with, so this is another thing that damages the student.
Working as a Java professional, I've noticed there are two things I almost never write: graphical user interfaces, and
Here's the first object a student should write:
public class Greeter {
public String getGreeting() {
return "Hello World!";
}
}
Unlike
public class Greeter {
private String name;
public Greeter(String name) {
this.name = name;
}
public String getGreeting() {
return "Hello, " + name + "!";
}
}
This moves us on to instance variables, constructors, and we can go on a quick tangent about the slightly weird
But if we don't have a main method, how do we run anything? Simple. Think of a Smalltalk environment, or of those tools that use introspection to allow you to test arbitrary EJBs. Provide the students with a “learning environment” that allows them to test the behaviour of the objects they have just written by sending them messages, and viewing the results. The hot-swapping introduced in Java 1.4 would allow a certain degree of on-the-fly debugging and immediate “if I do this, it changes the behaviour like this” feedback.
Ideally, such an environment would let students create objects, inspect them, pass them around, maybe even step through code when necessary. The basic idea, though, is once again we're immersing the students directly into the real world of Java programming - thinking in terms of objects and messages, not procedures and short-lived programs.
It would also free the students from having to immediately dive into AWT. The learning environment would be fully graphical, allowing direct manipulation of objects, so the “create a button that sums the two numbers in the text fields” problem would no longer be a necessary evil of Java tutoring.
Eventually, eventually, you would introduce the students to ways of making objects work outside the learning environment. The time to do that would be after the students understood what “public”, “static”, “void” and “String[]” mean.
|
||
![]() |
Copyright 2002 © Charles Miller |
![]() |