Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This seems like a fairly complicated interface structure. Are you sure each of the interfaces you're defining here is actually inherently meaningful and useful? Does it need such a degree of specificity in the lower level interfaces, and are the higher level interfaces specific enough to be useful?</p> <p>I'm not sure what you're referring to when you say that an interface extending another interface doesn't incur the same "contract enforcement" as a class. Remember that an interface doesn't implement anything, and so in deriving one interface from another, you're merely extending the contract that must be implemented by implementing classes. The members of the parent interface are implicitly included in the contract specified by the child interface. For example:</p> <pre><code>interface A { void Foo(); } interface B { void Bar(); } class C : B { void Foo(); void Bar(); } </code></pre> <p>Class <code>C</code> must implement both <code>Foo</code> and <code>Bar</code>, since <code>B</code> "inherits" <code>Foo</code> from <code>A</code>.</p> <p>You may also like to look into explicit interface implementation; see <a href="http://msdn.microsoft.com/en-us/library/4taxa8t2%28VS.80%29.aspx" rel="nofollow">here</a> and <a href="http://msdn.microsoft.com/en-us/library/ms173157.aspx" rel="nofollow">here</a>.</p> <p><strong>Update</strong>: If a method takes different parameters in more specific implementations, then you probably need to rethink your interface structure. Take a step back and think about what <code>IAction</code> represents and how client code might use it.</p> <p>For example, suppose <code>IAction</code> defines a general <code>Execute()</code> method with no parameters, while more specific derivatives of <code>IAction</code> define more specific <code>Execute(...)</code> methods with parameters.</p> <p>What use, then is the "general" <code>Execute()</code> method? Since each of the specific implementations actually requires additional information in the form of the parameters of the method, what exactly should the parameterless <code>Execute()</code> do?</p>
 

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