Note that there are some explanatory texts on larger screens.

plurals
  1. POOrganizing interfaces
    primarykey
    data
    text
    <p>I am just reading <em>Agile Principles, Patterns and Practices in C#</em> by R. Martin and M. Martin and they suggest in their book, to keep all your interfaces in a separate project, eg. <em>Interfaces</em>.</p> <p>As an example, if I have a <em>Gui</em> project, that contains all my custom Gui classes, I will keep their interfaces in the <em>Interfaces</em> project. Specifically I had a CustomButton class in <em>Gui</em>, I would keep the ICustomButton interface in <em>Interfaces</em>.</p> <p>The advantage is, that any class that needs an ICustomButton does not need a reference to <em>Gui</em> itself, but only to the much lighter weight <em>Interfaces</em> project.</p> <p>Also, should a class in the <em>Gui</em> project change and thus cause it to be rebuilt, only the projects directly referring to the CustomButton would need recompilation, whereas the ones referring to the ICustomButton may remain untouched.</p> <p>I understand that concept, but see a problem:</p> <p>Lets say I have this interface:</p> <pre><code>public interface ICustomButton { void Animate(AnimatorStrategy strategy); } </code></pre> <p>As you can see, it refers to AnimatorStrategy, which is a concrete class and therefore would sit in a different project, lets call it <em>Animation</em>. Now the interface project needs to refer to <em>Animation</em>. On the other hand, if <em>Animation</em> uses an interface defined in <em>Interfaces</em>, it needs to refer to it. </p> <p>Cyclic dependency - "Here we come".</p> <p>The only solution for this problem, that I see, is, that all methods defined in the interfaces take inputs that are themselves interfaces. Trying to implement this, will most likely have a domino effect though and quickly require an interface to be implemented even for the most basic classes.</p> <p>I don't know if I would like to deal with this overhead in development.</p> <p>Any suggestions?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload