There is no good excuse for an empty class. If it’s being used simply as a common extension point, it should be replaced with an
interface
. If it was stubbed in as a placeholder for future development it should be fleshed-out. In any other case, it should be
eliminated.
Noncompliant code example
public class Nothing { // Noncompliant
}
Compliant solution
public interface Nothing {
}
Exceptions
Empty classes can be used as marker types (for Spring for instance), therefore empty classes that are annotated will be ignored.
@Configuration
@EnableWebMvc
public final class ApplicationConfiguration {
}