JoC #21: Image manipulation – take two

      For every action, there is an equal and opposite criticism.
             — Steven Wright

We’re getting a bit further into image manipulation. I’ll show you how an actor can change appearance by dynamically changing its image while the program is running.

Download video

Concepts discussedimage manipulation, random numbers

Downloads: bounce.zip  bounce-v1.zip

JoC #20: Image manipulation – first contact

      What is important in life is life, and not the result of life.
            — Goethe

Today, we’re starting to look a little more at images. We’re starting with something quite easy: manipulating (programmatically) the world background. But this introduces important concepts which we will use shortly to do much more with images.

Also, this is another nice example of object interaction (as we know by now: one of the most important concepts in object -oriented programming). In this case, the world object interacts with an image object.

Download video

Concepts discussedimage manipulation


JoC #19: Class methods vs instance methods

      If can keep your head when all about you are losing theirs it’s just possible
      you haven’t grasped the situation.
            — Jean Kerr

Today, we’ve got some background stuff to discuss. Not much happening in terms of new functionality to our project, but important (and, no doubt, incredibly interesting) conceptual information.

Why is there sometimes a classname before a method call and sometimes a variable?

I’m sure all of us have had sleepless nights where we’ve been lying awake pondering this question. Today, it shall be answered!

Download video

Even if you’re not that interested in discussion of underlying concepts, but just want to GET STUFF DONE — still, watch this video. You can only become a good programmer (and get stuff done) if you understand what you’re doing.

I really want you not only to copy what I’m showing you, but become able to invent and create your own programs. For this, it’s important to get the concepts.

So, hit start, sit back for a few minutes, and learn something!

Concepts discussed: internal method calls, external method calls, static methods, instance methods 

JoC #18: Bouncy balls with mouse input

    If you have passion and focus, you can achieve things that amaze yourself.

And we’re back! I hope you used your couple of weeks space between Joy of Code episodes to catch up and get a bit of practice with Greenfoot — and now we’re off again.

This time, we’re talking about dealing with mouse input. Very important for many games and other interactive programs.

Download video

Concepts discussed: world act method, reacting to mouse input

A quick update

I know that some of you are waiting for the next Joy of Code episode. We are a having a little pause.

Just a quick note to reassure you: I have not stopped — there is more to come!

I am at a conference in the US (SIGCSE, in case you’re interested), and I have been travelling for over a week now. I will be on the road a little longer.

But the Joy of Code will continue when I’m back, in a week or so. Until then: Play with Greenfoot! Program! Enjoy!

Java 6 End-Of-Life shifted to November

This is possibly a case of

      Warning: Dates in your diary might be closer than they appear.

Oracle just announced that the “EOL date” for Java 6 has been shifted back. From July to November. While it is undoubtedly a relief for many that Java 6 has an additional four month of life left (for many of those few at least, who are aware of this at all) it still means one thing: End of life for Java 6 is in November! 2012!

Yes, that means this year. You didn’t know that, did you?

Now, this doesn’t mean that Java 6 will topple over dead on 1st November. It will, of course, continue to work for some time. But it does mean that Oracle will stop issuing updates and releases after that date for free. (You can still buy support from Oracle, but that will really only be an option for large businesses.)

So, while this will come as somewhat of a shock to some, it this too soon? That depends how you view it. Java 7 has been in full public release since July 2011, so it will be well over a year of the next major version being on the market by the time Java 6 bites the dust. Time enough for most to update?

Let’s look at where people really are. Here is the distribution of Java versions of users of BlueJ:

Java versions

BlueJ users by Java version

This shows us: Java 7 is currently used by just under a third of BlueJ users. (For Greenfoot, this number is a little lower than this.) About 3% still use Java 5.

So, while Java 7 has been out for a while, Java 6 is still by far the dominant version. The reality is: Many universities and schools update only infrequently, and updates to Java 7 haven’t happened yet in many places.

We would hope that this changes over summer: many educational institutions upgrade their lab software over the norther hemisphere summer break, so that might give a good boost to Java 7 before November.

But will most of the Java 6 installations disappear by then? Most likely not. Especially on Mac OS, it’s difficult: Java 7 isn’t even in public release for that platform yet.

So, if you’re responsible for Java on your institution’s machines: time to think about moving on!

 

JoC #17: Bouncy coloured balls

      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!

Download video

Concepts discussedclass structure, field, constructor, method, default constructor, changing images


JoC #16: Adding a score counter

      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!

Download video

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.

Concepts discussedobject interaction, constructor, field, local variable, assignment, external method call

Downloads:  trick-the-turtle-v4.zip

JoC #15: Object interaction (first encounter)

      The pure and simple truth is rarely pure and never simple.
            — Oscar Wilde

Today a long, and quite full episode. We encounter various very important concepts for the first time: local variables, class types and object interaction.

If you have questions left after watching this – don’t worry. We will look at all of this again in more detail in future episodes. And you can use the comments below to ask your questions (or make any other comments).

By the way, I just noticed I made a mistake. (Yes, that does happen!) There is a bug in the program that I’m writing in this episode. Can you spot it?

Download video

Concepts discussedvariable, field, local variable, assignment, class type, object interaction, external method call