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 #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 #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 #13: The structure of a class

      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.

Download video

Concepts discussedclass structure, class header, comments

JoC #3: Classes and objects

    If a man writes a book, let him set down only what he knows.
    I have guesses enough of my own.

          — Goethe

Alright, now it finally starts getting interesting! After the previous talk about installation, now we’re getting started actually doing stuff.

Watch this episode to get the first feel for working with Greenfoot, and see what classes and objects are all about.

Download video

Concepts discussed: class, object, method, instance, return value, return type, void, int, boolean

And, as I said in the video: Follow @JoyOfCode on Twitter to get updates when new episodes are posted.

Scenario download for this episode: hedgehogs.zip      (save and unzip before opening)