I am interested in justification and history of this issue. Basically, this rule looks very strange and I would like to know how this concept was invented.
What I found:
1. Initially, someone figured that methods, which do not access instance fields should be static, but didn't explained why.
2. Next other someone realized that the rule is wrong for non-private methods. So the rule is implemented only for private methods, but without explanation why
3. I also found that initially someone expected that the rule has (among others) performance meaning, but someone later realized that it is not true. I think it was a good moment to review sense of the rule, but the review was not performed.
I applied the rule to joda time library and 19 code smells was detected.
Do you think that code
----
/**
* Checks whether the period is non-null.
*
* @throws IllegalArgumentException if the period is null
*/
private void checkPeriod(ReadablePeriod period) {
if (period == null) {
throw new IllegalArgumentException("Period must not be null");
}
}
----
smells bad and ``++private static void checkPeriod(ReadablePeriod period)++`` smells good?
I think that the rule was based on wrong assumption, was heavy modified without review the sense and encourages to bad style coding. Effectively, it is anti-rule and should be deleted.