Checkstyle’s “AbstractClassName” check uses the following default pattern to check for class names that should be declared as abstract:
^Abstract.*$|^.*Factory$
I understand that classes starting with ‘Abstract’ are supposed to be declared as abstract. But why should this also hold true for classes ending with ‘Factory’?
Is this really best practice? And if so how should I name my factory classes instead?
The default regular expression came about from the Abstract Factory pattern – see http://www.apwebco.com/gofpatterns/creational/AbstractFactory.html.
I admit that I have not seen this naming convention used in the wild. It is a simple matter to change the check configuration to use the pattern:
Like always, Checkstyle should be used as guide as to what is best practice.