Silva
Silva
CC#
Created by Silva on 8/11/2023 in #help
✅ Receiving any instance of a generic class in a method, no matter what the generic type is.
Anyway, sorry if I derailed the conversation, but it did genuinely help me understand some more concepts! Thanks @ZZZZZZZZZZZZZZZZZZZZZZZZZ and @Denis for the help, and thanks for the genuinely interesting conversation! :)
167 replies
CC#
Created by Silva on 8/11/2023 in #help
✅ Receiving any instance of a generic class in a method, no matter what the generic type is.
I think it's more of a matter of where you want to be explicit, not as much as if it is or isn't explicit? "The first point is that both implementations provide the fundamental decoupling that's missing in the naive example - in both cases application code is independent of the concrete implementation of the service interface. The important difference between the two patterns is about how that implementation is provided to the application class. With service locator the application class asks for it explicitly by a message to the locator. With injection there is no explicit request, the service appears in the application class - hence the inversion of control." (highlight is my own)
167 replies
CC#
Created by Silva on 8/11/2023 in #help
✅ Receiving any instance of a generic class in a method, no matter what the generic type is.
https://martinfowler.com/articles/injection.html This I think represents a little bit what we are discussing
167 replies
CC#
Created by Silva on 8/11/2023 in #help
✅ Receiving any instance of a generic class in a method, no matter what the generic type is.
But I think I do understand what you are saying
167 replies
CC#
Created by Silva on 8/11/2023 in #help
✅ Receiving any instance of a generic class in a method, no matter what the generic type is.
If they create and store the publisher, then they are going to do something with publishers
167 replies
CC#
Created by Silva on 8/11/2023 in #help
✅ Receiving any instance of a generic class in a method, no matter what the generic type is.
Well, to be fair, I do think that my system is quite explicit:
this.pub = Facade.Publisher(...);

// Later
this.pub.Publish(...);
this.pub = Facade.Publisher(...);

// Later
this.pub.Publish(...);
167 replies
CC#
Created by Silva on 8/11/2023 in #help
✅ Receiving any instance of a generic class in a method, no matter what the generic type is.
Sure it's more contrived, they need to add more lines of code to be able to do something that isn't ideal, but they can still do that
167 replies
CC#
Created by Silva on 8/11/2023 in #help
✅ Receiving any instance of a generic class in a method, no matter what the generic type is.
or from anywhere really
167 replies
CC#
Created by Silva on 8/11/2023 in #help
✅ Receiving any instance of a generic class in a method, no matter what the generic type is.
Although, I could argue that the user can still configure the DI framework so they can call RemovePublisher from a DTO
167 replies
CC#
Created by Silva on 8/11/2023 in #help
✅ Receiving any instance of a generic class in a method, no matter what the generic type is.
I guess I should have seen that coming
167 replies
CC#
Created by Silva on 8/11/2023 in #help
✅ Receiving any instance of a generic class in a method, no matter what the generic type is.
Hahah
167 replies
CC#
Created by Silva on 8/11/2023 in #help
✅ Receiving any instance of a generic class in a method, no matter what the generic type is.
But if we are coding on the principle that the user is dangerous, then we need to safeguard against everything
167 replies
CC#
Created by Silva on 8/11/2023 in #help
✅ Receiving any instance of a generic class in a method, no matter what the generic type is.
Sure
167 replies
CC#
Created by Silva on 8/11/2023 in #help
✅ Receiving any instance of a generic class in a method, no matter what the generic type is.
If I was using DI I'd have to have one point where I'd register all my events, and then both invokers and observers would have to request a reference to that event. In my system, it's all abstracted behind one class.
167 replies
CC#
Created by Silva on 8/11/2023 in #help
✅ Receiving any instance of a generic class in a method, no matter what the generic type is.
With an abstraction over the top to simplify the api
167 replies
CC#
Created by Silva on 8/11/2023 in #help
✅ Receiving any instance of a generic class in a method, no matter what the generic type is.
But a central place to register those observers on the events
167 replies
CC#
Created by Silva on 8/11/2023 in #help
✅ Receiving any instance of a generic class in a method, no matter what the generic type is.
When what I have is effectively a number of events that I can invoke at any time, and a number of observers interested in those events
167 replies
CC#
Created by Silva on 8/11/2023 in #help
✅ Receiving any instance of a generic class in a method, no matter what the generic type is.
I do still have a hard time making the connection that "it's intuitively better to just jump from the system I'm implementing to a DI framework"
167 replies
CC#
Created by Silva on 8/11/2023 in #help
✅ Receiving any instance of a generic class in a method, no matter what the generic type is.
Right
167 replies
CC#
Created by Silva on 8/11/2023 in #help
✅ Receiving any instance of a generic class in a method, no matter what the generic type is.
If it is scoped that way
167 replies