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