Have you heard of hashCode() and equals() in Java and the eternal discussions around this? And you know by now the implications of having a messed up relationship in between hashCode and equals so you make sure every time you implement a class with an equals() you have to make sure hashCode() follows suit right? […]
Posts Tagged: object oriented programming
About composition and delegation in the Groovy language
When dealing with OOP languages, composition over inheritance has been the preferred approach for a while now as it offers a greater flexibility in most cases. Before you start, I’m not going to get into that dispute whether one should opt for inheritance or not, enough to say that there are cases where composition is […]
Why You Should Use Default Methods in Java 8 Interfaces
With Java 8, Oracle introduced the concept of “default methods” in interfaces (and if you really haven’t heard of this — wtf?? — you can read more here about it: https://docs.oracle.com/javase/tutorial/java/IandI/defaultmethods.html). This argue some is a step towards multiple inheritance and as such should be banished from the oh, so pure! Java language. Others point out […]
Of Validating Inputs in Java and Designing for Extension
I read recently an article on DZone titled “Defensive Programming: Why You Shouldn’t Check Input Parameters for Validity” (by the way, you can find the article here: https://dzone.com/articles/defensive-programming-via-validating-decorators) and it made me think — and write this post 🙂 For those of you who don’t have the patience to read the full article, the author […]