Defining Factory Functions for Objects with Multiple Constructors
- Dominant language
- C++
- Stars
- 1.9k
- Forks
- 202
- PR merge metrics
- No merged PRs in 30d
Description
When I originally needed to create a DI Object which would be passed some arguments I was guided by the "Scaling Doubles Injection Test", and looked at `ScalerFactory`, however my object didn't have any additional dependencies, so I had no substitute for the `Multiplier*`, and so I just removed it.
In the old Business Tax Objects system, some of the objects have multiple `::Create` methods, so far I've been translating objects that had only one Create Method and therefore also only one private Constructor and so this hasn't been a limitation, when working with fruit.
The object I'm trying to create receives a Factory, as far as I can see, just as you have a `Multiplier*` parameter in your constructor, I can substitute it for a `SomeObjectFactory` parameter
```cpp
using SomeObject = std::unique_ptr;
using SomeObjectFactory = std::function;
```
However I am unsure on what step to do next to support multiple constructors.
So far I see that there is a 1 to 1 relation ship between `constructors` and `getXXXComponent functions`
Does this mean I will need two sets of getXXXComponent functions?
```cpp
using SomeObjectFactory = std::function;
using SomeObjectFactoryVer2 = std::function;
fruit::Component getSomeObjectOneParam();
fruit::Component getSomeObjectThreeParams();
Contributor guide
Assessment
This issue has not been assessed yet.