rspec/rules/S3058/java/rule.adoc

22 lines
577 B
Plaintext
Raw Normal View History

2021-04-28 16:49:39 +02:00
Overriding a parent class' method implementation with an ``++abstract++`` method is a terrible practice for a number of reasons:
* it blocks invocation of the original class' method by children of the ``++abstract++`` class.
* it requires the ``++abstract++`` class' children to re-implement (copy/paste?) the original class' logic.
* it violates the inherited contract.
2021-04-28 16:49:39 +02:00
== Noncompliant Code Example
----
public class Parent {
public int getNumber() {
return 1;
}
}
public abstract class AbstractChild {
abstract public int getNumber(); // Noncompliant
}
----