Description:
SDMC detects if all subclasses of a class vary only in methods that return constant data. If so, it suggests to change the methods to superclass fields and eliminate the subclasses.
Example:
abstract class Person {
abstract boolean isMale();
abstract char getCode();
}
class Male extends Person {
boolean isMale() {
return true;
}
char getCode() {
return 'M';
}
}
class Female extends Person {
boolean isMale() {
return false;
}
char getCode() {
return 'F';
}
}