-
-
Notifications
You must be signed in to change notification settings - Fork 491
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SerializerBuilder interface for IoC #517
Comments
Why would you want to inject a SerializerBuilder ? Why not inject an |
Well, what's the role of the |
Looking at the source it looks like it essentially exists to decouple the I guess the issue with not being able to inject is this where you want different functionality in different consumers. So, as an example and picking a method at random, one class wants a serializer with TagMapping and one doesn't. Then you have to register multiple serializers and start tightly coupling the implementation to a particular IoC. Where as if you could just inject the factory you could new up new ones however you want and also have good IoC and unit tests, etc. |
The serializer is just an aggregator of many different components that are composed together. The SerializerBuilder allows you to configure the serializer without needing to know all the details of that composition, but its interface is coupled to the serializer implementation, so there's no point on having an abstraction for it. I believe that the use case that you describe is far from common. I think you would be better served to define your own factory interface with methods that make sense for your use case. |
If I recall the serializerbuilder and serializer are both not thread safe so you would need to scope them as transient object. I understand your desire for an interface around them, which I’m pretty sure serializer does. If we made the methods virtual instead of needing to maintain and interface would that suffice? |
Looking at the SerializerBuilder class this seems to be screaming out for an interface. This would allow for better IoC utilisation, particularly when wanting to mock dependanices for unit testing:
It would be trivial to add?
The text was updated successfully, but these errors were encountered: