Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>Is that the wrong approach for passing parameters through an interface so those same variables can be used elsewhere?</p> </blockquote> <p>Be careful not to confuse object instances with type declarations. A local variable of type <code>ISiteForm</code> is accessible in the block which it is declared. For example,</p> <pre><code>public void M() { ISiteForm s = new SiteForm(); } </code></pre> <p>If I declared <code>s</code> as a <code>SiteForm</code> the change does not make the object instance <code>s</code> any more accessible to other parts of the program.</p> <p>An interface does allow us to treat an object uniformly regardless of the underlying type of the object. </p> <p>E.G.</p> <pre><code>public void M(ISiteForm s) { var propertyName = s.FirstName; } </code></pre> <p>Here, I don't know or care if <code>s</code> is a type of <code>SiteForm</code> or some other type that happens to implement <code>ISiteForm</code>. The behavior is polymorphic.</p> <blockquote> <p><strong>Which would be laid out like this, so it could be implemented and referenced by the User Interface.</strong></p> </blockquote> <p>To that point, Interfaces can be used to decouple layers in an n-tier architecture. For example, you may create an Interfaces.dll. This DLL can house <code>ISiteForm</code>. The User interface and Business Logic can both reference this shared DLL. This design allows loose coupling by allowing otherwise unrelated objects to be passed between layers and helps to avoid <a href="http://en.wikipedia.org/wiki/Circular_reference" rel="nofollow">circular references</a>.</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