Daring ideas are like chessmen moved forward; they may be beaten, but they may start a winning game. — Goethe
In this and the next episode, we’re looking a bit more into how to set up object structures, and how to get them to interact. This is one of the most fundamental concepts of object-oriented programming, so you need to get your head around this.
We discuss this here with the example of integrating our counter object into a scenario.
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. — Brian W. Kernighan.
We’re leaving the ‘Trick, the turtle’ scenario this week to make something new completely from scratch.
The main purpose here is to piece together everything we have seen to far about the structure of a class, and create a complete new class (with fields, constructors and methods).
Yes, I know, this doesn’t sound too exciting. I can see from the video view numbers that videos dealing with review of concepts aren’t quite as popular as the ones showing new stuff.
So: Don’t worry. I’ve thrown a few interesting new things in as well: dynamically changing images, string concatenation and multiple constructors are some of them. Oh yes, and a first run-in with a runtime exception!
Habe Mut, dich deines eigenen Verstandes zu bedienen. — Immanuel Kant
Welcome back after a little break in putting out new episodes.
I was at a conference for a week or so (Melbourne, other side of the world!), and then I had to get settled into my time zone again, but I’m back! I still feel a little jet-lagged, so if my voice sounds even more drab than usual in this episode – I blame the time zones.
This episode deals with an incredibly important concept: object interaction. (It could actually also have been titled “Object interaction – a second look”.) We started to look at object interaction a little bit in Episode #15, and now we’re really getting stuck in. We’re throwing around terms like “object references” and “constructors”.
Yes, we’re slowly cranking up to a more professional level here. So sit back, switch your brain on, and watch. And of course — as always — after watching: Fire up Greenfoot, and get coding yourself!
Oh, and one more thing: I am showing how to implement a score counter here, because several people have asked me how to do that. So if you have a question, or something you want explained: tell me in the comments, and I’ll try to fit it in in one of the future episodes.
Update: This episode shows how to use a ready-made counter object. If you are interested in making such a counter yourself, you can now look at Episode 26.
We know accurately only when we know little; with knowledge doubt increases. — Goethe
It’s time to pause a little bit with our code writing and analyse what we have so far. We want to make sure that we properly understand what’s going on.
So, today you’ll get a deeper understanding of code structure and – as a bonus – find out a bit about comments.