Classes and Objects

There follow two lessons, which are straightforward and easy to follow, so there is no need to say much about them. The Passing Information lesson gives a nice illustration with code to compute monthly payments on a home loan. The rest of the lesson is fine, except that a paragraph on circles refers to another lesson without giving a hyper-link. It's not the end of the world, but it is annoying. I'll provide one.

And the top page of the Objects group is nicely explained, with links to the code for the classes behind the objects it uses. This is thoughtful, and certainly aids understanding.

Then it all falls apart with the lesson on Creating Objects. I'm not quite sure why we need this page. We've already seen objects created in the first lesson on classes, and we've seen them created in a different way in the second lesson on classes (with constructors). When I first read this lesson I wondered whether it was written deliberately to confuse, rather than to encourage new Java users, to put off the unworthy.

The term Instantiating in my opinion introduces unnecessary confusion for migrants from Visual Basic because it is used there in a slightly different context. VB doesn't use classes (or didn't the last time I looked), but if you write code for an object you can instantiate that object as often as you like. The effect is almost exactly the same, except that you don't have to call the first object a class; you just call it an object.

If I were writing the paragraph headed "Instantiating a Class" I'd call it "Creating an Object from a Class". It has the same meaning, but it just seems to me more consistent with the Java model and less VB-like.

And the paragraph "Initializing an Object" I'd call "Initializing a Reference Variable", and I'd put it right after the paragraph headed "Declaring a Variable to Refer to an Object" so that it flows and makes sense.

After the confusion of that lesson, the lesson entitled "Using Objects" is nicely laid out and explained.

Comments

Popular posts from this blog

A few notes on JavaScript

Forum Comments on Java Applets

Creating a Custom Swing Component