Replies: 1 comment 1 reply
-
I think this is reasonable though I'm not in favor of adding a new API for this. Instead, I think we can go with the solution you mentioned of setting the default value to the |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Recently I wanted to restrict the list of possible values for one of my factory so I could get several factories producing objects which can have some properties with unique/non overlapping values.
The thing is, my factory already define several custom generators for various properties of my objects and I didn't wanted to duplicate those. Also, I wanted to be able to do it on the fly (imperative style) (for example on test cases)
For example, I would like to do the following
I often encounter this case during my tests where I need my factory to produce unique objects or objects with some properties not having particular values (when you test filtering for some DAO for example).
At the moment, I've managed it by subclassing mysef the
ModelFactory
class but I'm wondering if it could be integrated in the library itself.Basically I'm just leveraging the
create_factory
function to create a factory, on the fly, inheriting the current factory and automatically reusing the same model. This is quicker to do than using thecreate_factory
function directly and feels less awkward because you don"t have to pass again the modelMaybe that could be done by simply updating the
create_factory
function to defaultsmodel
to the current__model__
if the factory is not an abstract factory.Cheers
Beta Was this translation helpful? Give feedback.
All reactions