Skip to main content

How do you teach Java?

Posted by mister__m on November 9, 2003 at 8:25 PM PST

To begin with, if you ever read any of my first blog entries, three months ago, when I had the time to write them :-P, you may have found this topic a bit unusual for a guy who likes to talk about APIs and JSRs. Well, I must say I consider both things equally important: those who just know things to themselves are not useful at all in some situations - if you have millions of lines of code to migrate and your client has a great, brilliant team, that only doesn't know Java (yet), for example - and vice-versa. But let's get back to the topic.

At Summa Technologies, my new professional home, we're not afraid of neither implementing nearly-impossible-to-write, mission critical software, nor mentoring and training teams so they are able to accomplish the nearly impossible tasks on their own. However, I must say the team I'm teaching right now is really special, in a good way. Part of them never were programmers really - they were just support team members. Others are average to very good skilled C/C++ programmers, whereas some of them have programmed in a hybrid C-based language, which is closer to Visual Basic in its essence than to C, to be fair. Finally, the last group is composed of people who simply never paid much attention to coding, but instead dedicated most of their professional lives to the analysis field.

While we generally expect the C++ programmers to perform better than the others, that's not what happens. The fact is that, generally, support team members write better code faster than most students. Why? Well, they have nothing to fight against! They don't think based on C or other language, they are able to face Java as pure Java, Java itself. That leads them to wonderful results. One of them was the first person ever who didn't know Java and was able to solve my classic "how-to-convert-this-expression-to-string" problem without doing it in an ugly, cumbersome way - which we call "gambiarra" or "gambi" for short, in Brazilian Portuguese. That made me really happy and proud of teaching them.

So, now you think the C++ or the other kind of programmers are the best after them, right? It is not that simple, actually. Some paradigms can stop most pure C and similar platform developers from producing accurate, well designed classes since they tend to write code before really understanding the problem they are trying to solve. They are used to write code, delete it as they notice it doesn't solve the problem and then rewriting it again and again till it works. When it happens, well, a considerable part of the code is just rubbish. But the analysts, well, once you tell them two or three times to stop trying to code if they don't know what they're doing, they listen to you! They spend 60% of the time thinking and 40% coding, very close to the ideal rate (80/20 for new problems).

Another common mistake programmers do: they try to think in Java! Why is it bad? They do it because they can "think" in their current programming language, since they are used to them for ages. Again, the problem is: you are not able to think in a language you don't understand! So, they must solve problems in a intermediary language, an internal analysis language we all developed as programmers and some of us forgot when we got good at our current programming language. That fact makes analysts perform better again, since this intermediary language is to them their natural language!

The last interesting fact is people find it much harder to understand object-oriented concepts than the whole language itself. Does it seem obvious to you? I think so, but the point it that, if you explain and expose a concept in every possible way, giving abstract examples they can relate to, real code examples with a few classes, draw clear and simple diagrams, make they explain the concept to you in their own words and they still can't apply the concept or even explain it to you the day after, what do you do to make them understand? I don't have a fixed answer for that question. I try to pay attention to the person so that I know what to do in that specific case. Eventually, I can get the person to understand the concept and then I am able to sleep in peace again :-D.

That is the coolest part about teaching: it makes you remember we are humans and that, no matter how common, simple, standard we look, we are unique. You cannot assume things about people. We react in unique ways. That makes us extremely beautiful pieces of design. Instances of a race, with different results for our equals implementation. We are not comparable or serializable, though. But we are all the same in essence. Belong to the same class, the same race. In fact, if we think this way, God is a far better architect than we will ever be.