Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should Interfaces Live In The Same Namespace As The Concrete Classes That Implement Them? [closed]

Is there a standard for how solutions/projects are organized in regards to interfaces and the classes that implement them? I'm working on a an MVP, DDD application and would love to hear feedback as to how others layout their projects and why they do it that way. Thanks!!

like image 224
Cognitronic Avatar asked Jan 26 '11 02:01

Cognitronic


2 Answers

They should live in the namespace that is logical for them; this means that there's no firm rule for whether or not they should reside in the same namespace. You'll find relatively abstract namespaces often don't live alongside their implementation, whereas interfaces that are more 1:1 with their implementors are more likely to remain alongside one another.

A more important consideration is to keep the interfaces consumable for reuse--normally this means more consideration given to what goes into the assembly alongside the interfaces, rather than the namespaces.

like image 194
STW Avatar answered Oct 06 '22 00:10

STW


Check Martin Fowler's pattern on Separate Interfaces, it might help you decide where to put them.

like image 43
Pablo Fernandez Avatar answered Oct 06 '22 00:10

Pablo Fernandez