Skip to content
October 16, 2008 / Ben Chun

Object Array Frustration

It may be true that I didn’t get enough sleep last night or eat anything before school and woke up late enough that I was almost late to school. Maybe so. Regardless, my AP class this morning was objectively terrible. Not that there weren’t individual successes and insights. There were. But the biggest insight was my own, and it wasn’t pretty when that light bulb went on.

I had assigned what I thought was a pretty simple lab, which has now been revealed to me as being totally contrived and false exercise that not only failed to teach anything but has perhaps pushed through enough conceptual territory so as to confuse students. I made a few mistakes, one of them covered by Simon Holland in his 1997 paper Avoiding Object Misconceptions under the heading “Objects are not simple records”. But the biggest problem is that students are not facile enough with the syntax and the concepts yet to go this fast. This is frustrating because I think they could be if my assignments were better and more focused.

I’m not taking the responsibility off students who haven’t done the assigned reading, but I’m glad to know sooner rather than later that I haven’t done what was needed to insure their understanding. This is what I saw today:

  • Despite having done homework involving arrays and being tested on arrays, some students do not really understand what an array is — or at least can’t do anything useful with one.* Java’s clunky array declaration syntax doesn’t help at all when you couple it with the shortcuts (string literals, array declarations, etc) and multiple ways to do the same thing. In a way, I wish that this course was in Python (one — and preferably only one — obvious way to do it) even though I don’t have as much experience with Python as I do with Java.
  • I sometimes write instructions like “use another loop to…” that seem arbitrary and so students tend to look for these cues instead of thinking independently. Of course, there are an equal number that disregard the instructions entirely and head off in a random direction…
  • Students have no idea what the purpose of Java’s classes might be, despite a chapter on Object Oriented design. This adds to my slight bias against an “Objects First” approach, although I am trying to keep an open mind. I do think should have stayed with simpler but more rigorous exercises using primitives and Strings until we had a motivation for using objects — encapsulation and data hiding. I should have pushed that hard immediately to clarify the meaning of a class. Without motivation, all my instructions to use objects probably seem arbitrary. I could tell, because some students were putting the program’s logic or even data into the class definitions. Why not? It’s just another place to put code. Instructional fail.
  • Why did I introduce inheritance already? No one got anything out of that except some ill-advised class diagrams, and we haven’t used it for anything. Again, no point to introduce this topic until there’s a use for it.

If I am going to follow the Head First Java book chapter by chapter (which I have been doing so far) then I have to keep a much tighter rein on the students, checking their reading, and forcing them to engage with the text. I have let them float along, thinking that assigning homework backed up with a quiz every few weeks would insure that they read and understood. Perhaps this illuminates flaws in the sequence I’ve somewhat blindly taught up to this point. I need to totally rethink this for next year. And this year, I wonder where to go next?

* Despite these struggles, I still can’t think of a better explanation than what’s given in the Sierra and Bates Head First Java chapter 3. (They say that variables are like cups, able to hold values. Primitives are items you put right into the cups, while object instances live outside the cups and the reference is like a remote control for that object which gets placed into the cup. So, then, an array is like a numbered tray of cups, and if you create instances to fill the array you are putting a remote in every cup.) I just think they try to read some of this stuff too much like English or too loosely. For example: I said Dog dogs[] = new Dog[25]; so why should I have to also say dogs[0] = new Dog();? It’s easy to for us to explain that this is because declaration and initialization are independent, but hard to make those words meaningful to people who have no real programming experience.

3 Comments

Leave a Comment
  1. Michael Ferraro / Oct 20 2008 9:54 pm

    Ahh, arrays… I use the Litvin text (Java Methods), and they don’t cover standard arrays until much later in the course — which proved to be fine last year. In line with rolling out OO concepts sooner than later, I have students using ArrayLists, manipulating them via add() and remove(), and determining # of elements via size(). A simple schema switch later will have students using dot notation with that funny length “class variable” provided for standard arrays.

    I’m not sure how other APCS teachers approach this issue, if they like to roll out standard arrays first or not. I just find ALs fit really well with the other stuff I’ve delivered. Oh, but then there’s the funky for-each() loop, which I end up teaching before standard for() loops. That one proves tricky for some students for sure. But after they get over the syntax, they start to figure it out.

    And they’ll get for() soon — after having used while() for long enough ;)

  2. Leigh Ann / Oct 28 2008 12:26 pm

    Ben,

    Going back to the “contrived” part of your movie example. Sometimes it helps to challenge students to start on a problem (even if you know they cant possibly finish it).

    What do I mean? http://www.netflixprize.com/ Clearly they are not going to work up a machine learning algorithm that will solve the problem, but one of the first questions that need to be asked in this problem is what information should we store about a movie and why? Now go and write a class that could be used to store that information.

    It also sets you up really well for future assignments like what strategies could you use to figure out if a person liked a movie? (simplest ones are what is the average movie rating, or rating for movies of that genre, etc.) There’s some good meat here and the fact that they are understanding (even a little bit) of a problem that someone will pay $1 million dollars for is nifty too.

Trackbacks

  1. Groovicus.com » Blog Archive » Primitive Objects versus Objects

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: