Daedalus
Daedalus

Reputation: 61

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!

Upvotes: 2

Views: 229

Answers (2)

Erre Efe
Erre Efe

Reputation: 15567

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 (i.e. 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.

Upvotes: 3

Henk Holterman
Henk Holterman

Reputation: 273374

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).

Upvotes: 5

Related Questions