Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You present four code samples, the 'simple' version so that you can explain the problem and then 3 'better' solutions to fix the problem. The only version that was self-explanatory was the simple version. So, I'm thinking of the poor developer that has to come in a maintain this next year (which might be you after forgetting what you did).</p> <p>So, could you consider a different mechanism altogether for "ensuring that all of the functions for each variable are instantiated". You mentioned a willingness to use T4 to auto-generate stubs for you during compile time. What about using <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=9aeaa970-f281-4fb0-aba1-d59d7ed09772&amp;displaylang=en" rel="nofollow noreferrer">Microsoft FxCop</a> to catch any instances where you forgot to add something.</p> <p>If you're not familiar with it, <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=9aeaa970-f281-4fb0-aba1-d59d7ed09772&amp;displaylang=en" rel="nofollow noreferrer">Microsoft FxCop</a> (also embedded in some flavors of Visual Studio) scans the compiled assemblies and evaluates hundreds of framework rules against your code, from proper spelling and casing of variables to unused locals. </p> <p>While I personally agree with most of the rules that Microsoft has bundled into FxCop, I think the real beauty of it is the ability to create your own rules. I have created rules that I add to FxCop that enforces CRUD principles, such as if you have a <code>CreateXxx</code> method, you must have a <code>DeleteXxx</code> method etc. So, if you identify a class that matches the pattern you desire, you can get a list of all variables {A, B, C} and then guarantee that FuncAB(A, B) exists and that FuncAC(A, C) exists etc.</p> <p>Then, even a junior developer would be caught out by FxCop the next time he implements IBiVariableFunction and forgets a function on a pair.</p> <p>Cheers, Adrian</p>
    singulars
    1. This table or related slice is empty.
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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