Everybody knows no one reads documentation. Hamcrest found an original way to warn users to use the org.hamcrest.BaseMatcher class instead of the org.hamcrest.Matcher interface.
Look at the interface yourself.
They added a dummy deprecated method called _dont_implement_Matcher___instead_extend_BaseMatcher_ in the interface.
I am still unsure whether I will ever use this in my own projects. But when this method appeared in my code today I could not help but look at it. It was then totally clear that I was not doing what they wanted me to do. I’ve seldom seen documentation that obvious.
There will be some troubles doing so, for example sonar will have trauma and developer mail box will be spammed
What do you mean about ‘developer mail box will be spammed’? Because there will be an warning in Sonar?
If I remember correctly you can always tell Sonar to ignore warnings coming from a class.
You’re right that there might be issues with some tools – but then there might be issues because users of your API implement an interface that might change in the future.
I almost had a cardiac arrest when I read your title. Why wouldn’t you want your users to use interfaces, that’s what interfaces are for… Then I understood that we don’t have the same meaning for user nor for interface!
Keep on ducking, my heart has restarted!
Yes, I was stunned by this method. It really matches my programming style : you know, nobody want to read the f***king manual
especially developers.
You want to get a lib in your classpath and start using it directly ! APIs are so well written this days. If you are addicted to CTRL+Space to get completion, a method like that is really what you expect to truly helping you. Moreover, the first ‘_’ character makes it appearing on top of all methods in the completion pop-up.
@Abderrazak:
If that _practice_ is rejected by the Sonar _tool_, it just does not matter if it makes sense for _people_. Do you remember the first principle of the agile manifesto ?
@jfproulx Hope it wasn’t too painful
@Eric Have you ever used a similar approach in your own code? Just wondering how people reacted