Default constructor is good or evil? Checkstyle and PMD are opposite here

Viewed 7413

Checkstyle says:

Class should define a constructor.

PMD says:

Avoid unnecessary constructors - the compiler will generate these for you.

Who is right? Or let's put it this way - what are the pros and cons of having an empty default ctor in a class?

9 Answers

I'm inclined to go with writing code only when it's needed. If you don't need any other constructors, go with having the compiler generate it for you. Else, code all the constructors you need.

Related