Subclassing behavior should be designed with maximal hermetization principle in mind - choosing most restrictive access level possible.
Declare class final unless you explicitly design it to be inheritable. For non final class declare all instance members as final and type members as static except for those you explicitly design for overriding.
When designing a module prefer public for non final class unless you explicitly design it to be inheritable by external clients. For open class prefer public for members except for those you explicitly design for overriding by external clients.
Every point that can be overridden increases complexity, thus it should always be a conscious choice to add it.
Subclassing behavior should be designed with maximal hermetization principle in mind - choosing most restrictive access level possible.
Declare class
final
unless you explicitly design it to be inheritable. For non final class declare all instance members asfinal
and type members asstatic
except for those you explicitly design for overriding.When designing a module prefer
public
for non final class unless you explicitly design it to be inheritable by external clients. Foropen
class preferpublic
for members except for those you explicitly design for overriding by external clients.