Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here's what I consider a best practice, do with my developments and suggest to all of my clients:</p> <ol> <li>Start with your test (or specification, if you're into BDD). Production classes and methods that you pull from your tests should be <strong>public</strong>. <ul> <li>Note: If you're developing in .NET, you may wish to consider using the <strong>internal</strong> keyword (and adding the <strong>InternalsVisibleTo</strong> assembly attribute to your production assembly, so that your test project can use the code) instead. Then you would make it <strong>public</strong> only if another <strong>production assembly</strong> depends on it.</li> </ul></li> <li>Any method that you create as part of the <em>refactoring</em> phase of your TDD should be made <strong>private</strong>. </li> <li>Make helper methods <strong>protected</strong> only when a derived production class needs them.</li> <li>Any method created in the refactoring phase (now private or protected), that you need in <strong>another production class</strong> should be <strong>extracted</strong> to a helper class and made <strong>public</strong> (or <strong>internal</strong> in .NET, and any language that supports the concept). </li> <li>If the helper class is needed in <strong>another assembly</strong>, then: <ul> <li>If the <em>other</em> assembly already depends on the helper class' assembly, make the helper class <strong>public</strong> (if it isn't already).</li> <li>If the other assembly does <strong>not</strong> depend on the helper class' assembly, extract the helper class to a <strong>helper assembly</strong> (the best fit, or a new one) and make it <strong>public</strong>. Be sure to make the original assembly reference the new helper assembly, if it doesn't already.</li> </ul></li> </ol> <p>This should pretty much cover all of your cases.<br> Hope this helps.</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