Skip to content
This repository has been archived by the owner on Mar 27, 2021. It is now read-only.

In affected IT.java's, replace inheritance flags with polymorphism #687

Open
sming opened this issue Aug 24, 2020 · 0 comments
Open

In affected IT.java's, replace inheritance flags with polymorphism #687

sming opened this issue Aug 24, 2020 · 0 comments
Assignees
Labels
codebase quality high level issues pertaining to improvements / problems with the codebase's quality component:all an issue that pertains to the whole codebase

Comments

@sming
Copy link
Contributor

sming commented Aug 24, 2020

or in more mechanical terms:

replace:

flags in IT.java base classes like protected boolean subclassHasFeatureX = true;
+
tests for that flag in the base class e.g. assumeTrue("Test huge row key write", hugeRowKey)
+
setting of said flag in concrete subclasses e.g. this.subclassHasFeatureX = false;

with:

  1. remove the flag
  2. keep the test in the base class but move the body of the test to a virtual method e.g.
@Test
public void FeatureXTest() {
    FeatureXTestImpl();
}

public void FeatureXTestImpl() {
    // test guts
}
  1. in subclasses that do not support FeatureX, override FeatureTestImpl to be a no-op:
@Override
public void FeatureXTestImpl() { /* no-op */ }

et voila

no more flags or run time exceptions if the developer forgets that the subclass doesn't support feature X.

See the original comment here.

@sming sming self-assigned this Aug 24, 2020
@sming sming added codebase quality high level issues pertaining to improvements / problems with the codebase's quality component:all an issue that pertains to the whole codebase labels Aug 24, 2020
@sming sming changed the title Replace all non "Liskov principle" inheritance flags in integration test code with polymorphism (!!!) Replace all non Liskov Principle inheritance flags in integration test code with polymorphism (!!!) Aug 24, 2020
@sming sming changed the title Replace all non Liskov Principle inheritance flags in integration test code with polymorphism (!!!) In affected IT.java's, replace inheritance flags with polymorphism Aug 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
codebase quality high level issues pertaining to improvements / problems with the codebase's quality component:all an issue that pertains to the whole codebase
Projects
None yet
Development

No branches or pull requests

1 participant