What is the best practice on creating new non abstract classes?
In addition to that should all variables be final unless you need to change them?
Does it make sense to mark methods final in final classes?
What is the best practice on creating new non abstract classes?
In addition to that should all variables be final unless you need to change them?
Does it make sense to mark methods final in final classes?
Very good article of @yegor256: Seven Virtues of a Good Object
Point 7. His Class Is Either Final or Abstract
A good object comes from either a final or abstract class. A final class is one that can't be extended via inheritance. An abstract class is one that can't have instances. Simply put, a class should either say, "You can never break me; I'm a black box for you" or "I'm broken already; fix me first and then use."
I find the Yegor's approach is very useful in my daily work.