There has been lengthy discussion over what an appropriate API for the VariantLookup functionality should look like.
Currently, VariantLookup is an ABC with two concrete implementations - one for file-based lookups and one for cached, in-memory lookups.
An initial refactoring was begun in #62, to permit the user to interact with Primer3 without direct use of a VariantLookup.
In the course of #71, there was additional discussion over how we might want to expose (or hide) the various implementations.
An API that hides the details of implementation from the user might look as follows, making the current ABC and implementations hidden and storing the lookup as an attribute on a public class.
class VariantLookup:
def __init__(...):
...
self._lookup: _VariantLookup
if cached:
self._lookup = _InMemoryLookup()
else:
self._lookup = _DiskBasedLookup()
def query(...):
return self._lookup.query(...)
class _VariantLookup(ABC):
...
class _InMemoryLookup(_VariantLookup):
...
class _DiskBasedLookup(_VariantLookup):
...
Other points to take into consideration - we should be cautious of the constraints imposed by a common constructor since there will be some parameters specific to each concrete implementation1, and we should establish an initial set of parameters and methods that are universal (e.g. close())2.
There has been lengthy discussion over what an appropriate API for the
VariantLookupfunctionality should look like.Currently,
VariantLookupis an ABC with two concrete implementations - one for file-based lookups and one for cached, in-memory lookups.An initial refactoring was begun in #62, to permit the user to interact with
Primer3without direct use of aVariantLookup.In the course of #71, there was additional discussion over how we might want to expose (or hide) the various implementations.
An API that hides the details of implementation from the user might look as follows, making the current ABC and implementations hidden and storing the lookup as an attribute on a public class.
Other points to take into consideration - we should be cautious of the constraints imposed by a common constructor since there will be some parameters specific to each concrete implementation1, and we should establish an initial set of parameters and methods that are universal (e.g.
close())2.Footnotes
https://github.com/fulcrumgenomics/prymer/pull/71#discussion_r1805044436 ↩
https://github.com/fulcrumgenomics/prymer/pull/71#pullrequestreview-2434670717 ↩