expressing return semantics in interface definition
<p>I have an interface</p>

<pre><code>interface IFooWidget
{
     IWidget Get(string widgetName);
}
</code></pre>

<p>My question is - how do I tell implementers the return semantics for the error case?  I mean if they cant find the requested widget should they throw or return a null value. This seems a vital part of the interface definition but I cannot express it.</p>

<p>Seems like documenting it is the only way - it would be much nicer if I could somehow put it in compiler-speak rather than human-speak.</p>

<p>Just wondering if anybody has any solutions or thoughts...</p>

<p>Consensus Answer:</p>

<p>Interface define syntax not semantics. I was allowing myself to be seduced by the englishness of my method definition. Imagine if it was instead </p>

<pre><code>IWidget Fnargle(string wobbler);
</code></pre>

<p>Which is of course how it looks to the compiler. The call semantics were hinted at in the original question because I chose a method name and params that were supposedly helpful. But really I need to document all aspects of the semantics of the method - not avoidable</p>
