I know very well that such a question has probably already been published. Nevertheless, with the participation of IoC in this case and a lot of code, I saw a colleague in the company where I am new, made this question.
Scenario:
In the code base of one product, this colleague builds each interface, is implemented explicitly. The entire application is built on a structural map, but in some places specific types are used and such as
((IInterface)concreteClass).SomeMethod()
Background:
This colleague explained to me by asking that this concerns the explicit implementation of all interfaces, that they recently introduced StructureMap, and many people will still only use specific types. Thus, in essence, this is a means of “educating” people in a company.
My cents on this issue:
First of all, the transition to StructureMap was made a few years ago, and although this seems to make us use interfaces more, in my opinion, this is the wrong way. The way I see it, people who know about a particular type can see the implementation and easily understand what I showed above ... just drop it. Clear exchange or coding conventions will make this much better. If IoC is used and there is no specific class, then explicitly implanting an interface is completely useless.
I also heard that this can really ruin the inheritance, but I don't know an example. I also saw how John Skeet did not encourage him to be used as mentioned above, but rather the way he was intended to be used, for example with IEnumerable <> and other name conflicts.
Can someone shed some light on this question for me. Pros and cons (although I am very biased not to do this, therefore, my post is here) and especially the reasons why this or that.
Thanks!
Edit: I know very well that this is not a question of right or wrong, and there is no real answer. It is more a question to learn to know the scarcity of each approach. Why should I use one script for a different approach?