JoC #25: Dealing with errors

      We learn wisdom from failure much more than from success. We often discover
      what will do, by finding out what will not do; and probably he who never made a
      mistake never made a discovery.
            — Samuel Smiles

We’re talking about errors today. I’m sure you all have – like me – got your fair share of errors when you were programming. I’ll talk a bit about how to go about investigating what went wrong when you get an error.

In doing this, we’re discussing the important distinction of synax errors and semantic errors, and we’re learning to deal with both. This includes reading stack traces.

Download video

Concepts discussed: syntax errors, runtime errors, stack trace, exception

JoC #24: Smoke and mirrors

      The ideals which have lighted me on my way and time after time given me new courage
      to face life cheerfully, have been Truth, Goodness, and Beauty. . . . The ordinary objects
      of human endeavour — property, outward success, luxury — have always seemed to me
      contemptible.
            — Albert Einstein

One more quick one about image effects: a smoke effect to be precise. I’ll show you how to create this really cool effect just with what you know already. Hopefully, this will give you some ideas of more cool effects that you can do on your own.

Download video

Concepts discussedimage manipulation, visual effects, animation

Download: The project can be downloaded from the Greenfoot book website.

 

JoC #23: Animating the image

      A positive attitude may not solve all your problems,
      but it will annoy enough people to make it worth the effort.
            — attributed to Herman Oliver Albright

A last little bit before we leave our coloured circles behind: an animation. In this case, it’s a very simple one: fading out the circles. But it shows an important technique: The appearance of an actor can change all the time, if we want to. This is the basis for many visual effects.

And, we finally see an if-statement with an else clause! I can’t believe that it took this long for this to pop up.

Download video

Concepts discussedtransparency, dynamically changing images, if-statement


JoC, Teacher Commentary 22: Tracing control flow

      Mathematicians are like Frenchmen: whatever you say to them they translate
      into their own language and forthwith it is something entirely different.
            — Goethe, Maximen und Reflexionen

Tracing control flow (either through control structures, such as if-statements or loops) or through method calls, is hard for beginners.

This episode shows you how to use the debugger to make this clearer.

Download video

Concepts discussedcontrol flow, tracing, breakpoints, debugger

JoC #22: Refactoring for good style

      We are accustomed to see men deride what they do not understand, and snarl
      at the good and beautiful because it lies beyond their sympathies.
            — Goethe

Okay, time to get a little more professional again: Let’s clean up our code a little.

Writing in good style is really important, so today I’ll show you a bit about refactoring. Especially, we want to create short, clear methods. (The technical term for it is cohesion – we want highly cohesive methods.)

Download video

Concepts discussed: methods, refactoring, style, cohesion

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-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!