Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove generic parameter from BoskDriver #25

Merged
merged 3 commits into from
Aug 24, 2024

Conversation

prdoyle
Copy link
Collaborator

@prdoyle prdoyle commented Aug 24, 2024

That generic parameter was used only to constrain the return type of initialRoot, and was not carrying its weight. Very little is lost if we verify the object returned by initialRoot at runtime, and in exchange, we simplify BoskDriver (a critically important type in this library).

When trying to add additional rigour around driver creation, it turned out there were cases where we had a generic root type R and driver class D and wanted to describe the driver as D<R>, but Java's generic type system is not up to this task. By dropping the generic parameter on the driver, we can now describe this type precisely as just D.

Some implementations of BoskDriver choose to be parameterized anyway, if it helps the implementation ensure type safety.

We've left DriverFactory parameterized because it turns out to be useful to ensure that certain kinds of related driver factories will accept the same root type; for example, in ReplicaSet.

This is just the automated refactor step. This commit doesn't build.

It was used only to constrain the return value from initialRoot, but
with further development, it has become clear that the costs outweigh
the benefits. It's hard to imagine an actual bug that this would move
from runtime to compile time, and even if there is one, this happens
during initialization so it would be caught very early.
@prdoyle prdoyle merged commit d6b58e5 into boskworks:develop Aug 24, 2024
1 check passed
@prdoyle prdoyle deleted the no-generic-driver branch August 24, 2024 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant