Placing Interfaces and Implementations in different assemblies

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
The next is from "Programming .NET Components" by Juwal Lowy:<br/> <br/> Because interfaces can be implemented by multiple components, its good practice to put them in a separate assembly from that of the implementing components.<br/> <br/> Sounds reasonable. But I am not sure that I really understand how I can implement this. As far as I understand programming via interfaces requires: <br/> Defining interface<br/>
<pre> public interface Interface
{
string About();
}
[/code]
Implementing interface
<pre> class Implementation : Interface
{
public Implementation() { }

#region Interface Members

string Interface.About()
{
return "Implementation";
}

#endregion
}
[/code]
Implementing a method for object instantiating.
<pre> public class Factory
{
public static Interface getInstance()
{
return new Implementation();
}
}
[/code]
I tried to find a solution but not sure it is good.<br/> <ol>
I placed IInterface,  Implementation and Factory in the sane namespace.
I placed IInterface in the "Interface" assembly and both Implementation and Factory in the "Implementation" assembly
</ol> In this case Implementation project requires a reference to "Interface" one and a client project using my component requires references to both "Interface" and "Implementation".<br/> How does this my solution look? Is there any better one?<br/> It looks that it would be better to also separate Implementation and factory classes in different assemblies. But this results in increasing of dlls (not sure if this is OK or not).<br/>

View the full article
 
Back
Top