Skip to content

[Incomplete] Testing Solution 1 - Explicit Factory Class#10

Draft
riley-dixon wants to merge 3 commits intodevelopfrom
rildixon/batch-mock-operation-1
Draft

[Incomplete] Testing Solution 1 - Explicit Factory Class#10
riley-dixon wants to merge 3 commits intodevelopfrom
rildixon/batch-mock-operation-1

Conversation

@riley-dixon
Copy link
Owner

@riley-dixon riley-dixon commented Dec 5, 2025

This PR is not a complete solution and does not work. However, I have left it as-is in case someone wants to take a look and see the idea I had here. This attempted to use a Generic template Factory that will automatically take a variadic list of arguments and match it to an appropriate constructor at compile time. If no constructor is found, a compiler error is issued. The benefit of this approach is not needing a specially typed Factory for each subclass we want to create a factory for.

Ultimately, I think this approach is incompatible with using a virtual type to allow for both a GenericFactory<Real> and GenericFactory<Mock> to be passed into the same function.

Edit: Fix hidden <> arrows.

This is not a complete solution. This was an attempt to use a
templated generic factory that would match a call to make
an instance to the templated constructor. This mechanism would
choose the most suitable constructor if it is overloaded, or fail
at compile time if no suitable constructor is found.

The most obvious code smell is that in order to get this to compile,
a dummy "IFactory<IBatchOperation>" class needs to be inherited from.
This is so that we do not need to declare the implementation of
BatchOperation in the submit_operations() signature. IFactory is
empty and does not actually contain the functions we are interested
in. Those instead lie with the GenericFactory which can't be listed
in the signature as GenericFactory needs to know the implementation.

I am leaving this here in case anyone wants to take a peek at the diff
and has an idea if this is worthwhile to pursue.
@riley-dixon riley-dixon marked this pull request as draft December 5, 2025 22:49
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