Interface question...

  • Thread starter Thread starter craig
  • Start date Start date
C

craig

I have a quick question regarding the use of interfaces...

Assume I have a class A that needs to interact with another class B.
Classes A nd B are in different assemblies.

Now, in order to assure that the interaction between classes A and B works
properly, class A assumes that class B implements a certain interface I.

Where is the best place to define interface I? What assembly should it be
defined in? Are there any best practices for doing this?

Thanks!
 
I have a quick question regarding the use of interfaces...

Assume I have a class A that needs to interact with another class B.
Classes A nd B are in different assemblies.

Now, in order to assure that the interaction between classes A and B works
properly, class A assumes that class B implements a certain interface I.

Where is the best place to define interface I? What assembly should it be
defined in? Are there any best practices for doing this?

Thanks!

If there are circular dependencies between the assemblies if it goes
into one of them, try it in a separate assebmly, assuming there are no
other dependencies
 
craig said:
I have a quick question regarding the use of interfaces...

Assume I have a class A that needs to interact with another class B.
Classes A nd B are in different assemblies.

Now, in order to assure that the interaction between classes A and B works
properly, class A assumes that class B implements a certain interface I.

Where is the best place to define interface I? What assembly should it be
defined in? Are there any best practices for doing this?

Without knowing the context, it's hard to say. What about putting the
interface in a common assembly?
 
craig said:
Where is the best place to define interface I? What assembly should
it be defined in? Are there any best practices for doing this?

Since the assembly name becomes part of the type name for your interface,
you'll want to define the interface in a third assembly and reference it in
the other two.

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
 
Thanks for the input. I appreciate it.

I am still not sure I completely understand the logic behind the issue. But
our project has a common assembly where we are putting alot of miscellaneous
common classes, etc. I will go ahead and put the interface there and see
how it plays out.

Thanks again!
 
Back
Top