Skip to content

Sub class algorithm - one for all solution #18

Description

@ryucc

Intro

We want to mock this method

List<Integer> getList() {
   return new MyListImpl();
}

The most ideal target would be subclassing MyListImpl.

This might not be possible if MyListImpl is final. What is our next choice?

Previously, we did a DFS on MyListImpl, on the inheritance graph from MyListImpl to List, and use the closest class on the path to List.

But we can actually make a new class that implements every parent class of MyListImpl. This will have better robustness to class casting.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions