The given implementation for hashCode is somewhat a mystery. Some misconceptions about it confuse students. I try to explain it. Continue reading “Misconceptions about Object.hashCode()”
Category: Misconceptions
Common misconceptions on programming and computer science in general.
I try answerings questions in a facebook group and often stumble over the same misconceptions. These are merely my thoughts on the topic and not a substitution for a proper text book. A good book can sometimes leave out certain details but it would not lead you to a complete misunderstanding of the topic.
Generics
Generics have one thing in common with regular expressions: Students think they are an easy to use tool but they just end up with code they do not understand and can’t maintain. Regular expressions can often be replaced by well written and documented code. But you can’t just replace generics. A student using collections with generic type parameters but not fully understanding the concept is still better than one using “raw” collections. And it’s often ok to use something just to get familiar with the idea before learning the theory. The downside is that many misconceptions emerge from this approach of teaching. Many start using Generics when they don’t even know about the Liskov Substitution Principle, which makes things even more confusing. In this post I try to explain some of the common misconceptions on generics in Java.
Continue reading “Generics”Abstraction vs abstract
Abstraction is very important in Java. And there’s the keyword abstract. But the use of abstract is not abstraction. It’s a common misconception that the abstract keyword is used for abstraction.
Continue reading “Abstraction vs abstract”
OOP isn’t about inheritance
Any book on OOP must explain inheritance, simply because it’s an important part of OOP in many languages. And since it’s so hard to explain and understand a large part of the book will be just about inheritance. This may lead to the false impression that OOP is just about inheritance.
Regular Expressions
I often notice that many students of programming do not understand the actual meaning of regular expressions. And I have seen online tutorials and even books that do not explain properly what regular expressions are.
Continue reading “Regular Expressions”Misnomer: String.length()
The method String.length() gives the length of the String, right? Or does it?
Is a Constructor a Method?
Why a constructor is not a method.
No, it’s not. In reflection both extend Executable, but Constructor does not extend Method. It is a common misconception that constructors are methods and often asked about at job interviews.