You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The above mentioned helpers isTimeType() and isSpecialType() however seem out of place as Specimen-specific information is shared across classes, one of which should not have the responsibility to "know" this information.
I'd like to refactor the code to allow each Specimen to decide on its own whether it can handle a specific type, removing this responsibility from SpecimenType.
This will have the following advantages:
Specimens are self-contained
SpecimenType can be simplified by removing methods
SpecimenFactory can be simplified by replacing the if-else-chain by a simple loop
It will be easier to register custom Specimens in the future, e.g. for expanded support of KotlinFixture
The text was updated successfully, but these errors were encountered:
This will add two things to each specimen: a static method to determine
what type it supports, and a "Spec" that can create the related
specimen.
Refs: #109
I noticed that
*Specimen
-classes have a weird relationship to theSpecimenType
-class.In order to decide whether a specific Specimen can be used for a given
SpecimenType
, theSpecimenFactory
asks theSpecimenType
.Example:
SpecimenFactory
:SpecimenType
:It seems weird to me that a specimen cannot decide for itself. It also introduces some oddly specific "configuration" in the
SpecimenType
like:...which in this case covers some classes Fixture cannot instantiate out-of-the-box and hence has to defer to the
SpecialSpecimen
.Some helper-methods in
SpecimenType
seem reasonable as they are simply forwarding class-information, e.g.The above mentioned helpers
isTimeType()
andisSpecialType()
however seem out of place as Specimen-specific information is shared across classes, one of which should not have the responsibility to "know" this information.I'd like to refactor the code to allow each Specimen to decide on its own whether it can handle a specific type, removing this responsibility from
SpecimenType
.This will have the following advantages:
SpecimenType
can be simplified by removing methodsSpecimenFactory
can be simplified by replacing the if-else-chain by a simple loopThe text was updated successfully, but these errors were encountered: