rspec/rules/S3058/java/rule.adoc
2022-02-04 16:28:24 +00:00

38 lines
843 B
Plaintext

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.
== Noncompliant Code Example
[source,java]
----
public class Parent {
public int getNumber() {
return 1;
}
}
public abstract class AbstractChild {
abstract public int getNumber(); // Noncompliant
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::message.adoc[]
'''
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]