简体   繁体   中英

Yes or No? Can I divide interface and implementing classes in different assemblies?

I'm new at programming, but I am doing my best to learn!

I have an application where i have to inject an IView into my ViewModel. This means the IView interface should be located in the ViewModel assembly, and not in the View one, or i'd break MVVM rules adding a reference from VM to View assembly.

So my question is: is it absurd to divide interface and implementing classes in two different assemblies, or is this the right way to proceed?

Thank you all very much!

is it absurd to divide interface and implementing classes in two different assemblies,

No, it is quite common. It already happens when your classes implement INotifyPropertyChanged for instance.

In WCF it is a (recommended) practice to put the Service interfaces in a separate assembly (ie in an assembly that contains only interfaces).

That's precisely what an API contains. A bunch of interfaces that you implement in order to interact with the system. That's the way certain artifacts (ie pluggins ) are implemented. So it isn't absurd.

As I see you put two languages on the question tag, you get another advantage with .NET. You can declare your interfaces in one language and implemented them in another one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM