Head First Java, 2nd Edition

Read HFJ online

2: Head First Java, 2nd Edition A Trip to Objectville

The big picture

As page 27 explains, this chapter helps us get out of main and really embrace the whole Object Oriented stuff that Java is supposed to be about. If your previous exposure to Java was all about writing programs where there was only one class, most of your code was in the main, and if you did make other methods, they were all static, then this Chapter is the antidote.

Chapter 2, page-by-page

page 27

Page 27 is about “the big picture” of this chapter–see comments above.

page 28

Page 28 starts a little story about Larry and Brad, and an Aeron chair. In case you don’t know, Aeron chairs are supposed to be really comfortable, but they are also really expensive.

(Back in the days of Silicon Valley excess (dot-com bubble days), they were all the rage at companies with too much money and not enough sense–see http://en.wikipedia.org/wiki/Aeron_chair)

This is sort of the hallmark of the Head First books—telling a story to try to pull you in, and teaching something about Java on the way. The code they are writing is sort of silly, but the concepts are important, so suspend your disbelief and go with it.

page 29

“The spec always changes”. This is a big part of what good software design is about—making sure you design things in a way that you are prepared for change. Its one of the reasons I want you to write lots of code (for the choice points exercises) that become the basis for building something bigger later—so that you can see how, as you build on previous code, that code something has to change to accommodate new needs.

As you can see, the point here is that some designs accomodate change more easily than others.

page 30-32

On pages to 32, the discussion continues and we start to get into inheritance.

pages 33-34

Pages 33 and 34 invite you to really think about Object Oriented design–the choices that you make when you choose the methods and attributes of a class. We’ll be doing a lot of that in this course, so I want to really invite you to spend some time on these two pages thinking about the content.

Having said that, I think the Television exercise on p. 34 is sort of dumb. I’d rather ask you to create an object for a CalendarEvent, or a UCSBCourse, or a UCSBStudent, and think about what the methods and attributes would be–something you might actually use in a Java program.