When the @Override
annotation was introduced in Java 1.5, which feels like back in the days when the dinosaurs roamed the Earth, it was a good idea at the time because, amongst other advantages, it made your code self-documenting and it ensured you've spelt the method correctly.
Now it's 2018 and almost everyone writes Java using an IDE that already tells you whether a method is an override, typically using a little icon next to the method name or in the left margin of the same line. If I misspell the method, Java won't compile my class because there will be an unimplemented interface method, and I won't see the expected little icon so I'll know it's not an overriding method. It seems to me that the @Override
annotation more often clutters the code rather than documenting it or making it clearer. Yet I still use it for the sake of consistency with the existing codebase. But for a new project, do you really think that we still should be using the @Override
annotation? If so, why?
@Override
tells you, and the compiler for enforcement, it should be an override. The IDE only tells you the bare fact, not whether it's by design.override
as a keyword, built right into the langauge. It's a fairly new language (public release in 2014), and it's still required.