Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In what namespace should you put interfaces relative to their implementors?

Specifically, when you create an interface/implementor pair, and there is no overriding organizational concern (such as the interface should go in a different assembly ie, as recommended by the s# architecture) do you have a default way of organizing them in your namespace/naming scheme?

This is obviously a more opinion based question but I think some people have thought about this more and we can all benefit from their conclusions.

like image 698
George Mauer Avatar asked Sep 28 '08 21:09

George Mauer


People also ask

What is interface namespace?

A namespace can include interfaces, classes, functions and variables to support a single or a group of related functionalities. A namespace can be created using the namespace keyword followed by the namespace name. All the interfaces, classes etc.

Should interfaces be in separate project?

Because interfaces can be implemented by multiple components, it's good practice to put them in a separate assembly from that of the implementing components.

What is the interface of Visual Studio?

At its heart, Visual Studio Code is a code editor. Like many other code editors, VS Code adopts a common user interface and layout of an explorer on the left, showing all of the files and folders you have access to, and an editor on the right, showing the content of the files you have opened.

What are interfaces in VB net?

VB.NET Interfaces So, an interface is nothing but a collection of method and property declarations. An interface can declare only a group of related functionalities, it is the responsibility of the deriving class to implement that functionality. An interface is defined with the Interface keyword.


1 Answers

The answer depends on your intentions.

  • If you intend the consumer of your namespaces to use the interfaces over the concrete implementations, I would recommend having your interfaces in the top-level namespace with the implementations in a child namespace
  • If the consumer is to use both, have them in the same namespace.
  • If the interface is for predominantly specialized use, like creating new implementations, consider having them in a child namespace such as Design or ComponentModel.

I'm sure there are other options as well, but as with most namespace issues, it comes down to the use-cases of the project, and the classes and interfaces it contains.

like image 124
Jeff Yates Avatar answered Oct 11 '22 14:10

Jeff Yates