Eckel's remote control example
May 11th, 2004 by HenI’m teaching Java at the moment, and predictably using Bruce Eckel’s Thinking in Java as the text book. I was told that he had slides I could use in the class, but it seems not, so instead I’m making my own.
The first couple of weeks I went largely about my own business, giving an overview of Java that differed somewhat from Eckel’s and then trying to get the students to grokk the Java code->compile->run cycle.
The class is an accompaniment to a course on project management, so hopefully I can be forgiven for trying to keep it simple and not throw them into unit testing, pair programming or IDEs.
Anyway, I first skim-read TIJ 1st edition online, having just read Java in a Nutshell to learn how to do this thing we call Java back at university. I then got the 2nd edition cheaply a couple of years back in a sale, and now have the 3rd edition via the class. As it’s in the early chapters, I never really noticed this, but there exists a superb example with which to explain the concept of Objects and References.
Remote Controls [ P.78 ]. My TV has a remote control, a thing that points to it and lets me make it do things, such as report its state or change its state. My cable box also has a remote control, though due to the 4 buttons on the top, it is really 4 remote controls in one. In fact, one of those remote controls happens to point to my TV!
This is a superbly wonderful way in which to describe Java’s basic building block. I don’t know if Eckel was the first to come up with it, but I love it.
