rspec/rules/S3058/java/rule.adoc

37 lines
829 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
}
----
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[]