Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I usually document my controller actions with a short description of what that action is meant to do, for example:</p> <pre><code>/// &lt;summary&gt; /// Controller for viewing and updating the jobs list. /// &lt;/summary&gt; public class JobsController : Controller { /// &lt;summary&gt; /// Displays a list of all jobs for a given site. /// &lt;/summary&gt; /// &lt;param name="siteId"&gt;Id of the site to view jobs for.&lt;/param&gt; public ActionResult Index(string siteId); /// &lt;summary&gt; /// Displays a detail view of a single job. /// &lt;/summary&gt; /// &lt;param name="id"&gt;Id of the job to view.&lt;/param&gt; public ActionResult Detail(string id); } </code></pre> <p>It's not quite the same as my xml documentation for other classes because these classes will never be used directly, and so its more documentation of the site / page behaviour than anything else. That said I find it useful to have a description of what the action does and what the parameters are, and here is as good a place as any.</p> <p>Note that I don't include the path - not only because if the path changes the information is out of date, but also becasue it <em>should</em> be obvious by looking at the route mappings what the path will be anyway.</p> <p><strong>Update / response to comments:</strong></p> <p>This sort of documentation may seem entirely pointless as the classes are pretty much self describing anyway, however on well named methods in properly structured code <em>this is usually the case with XML documentation anyway</em>. I still believe that this sort of documentation adds value however:</p> <ul> <li>It clarifies what the class / method / parameter does in plain english</li> <li>In confirms that nothing special is happening (as opposed to someone just not bothering to write the documentation).</li> </ul> <p>Note that I <strong>don't</strong> document the return value as there is absolutely nothing useful that I can ever say about it.</p> <p>You also need to consider that this example is incredibly contrived - it could be that certain parametrs are JSON serialised data, or that a negative value means something completely different. My view on XML documentation is that you should either document nothing, or you should document everything (no matter how obvious). If only half your methods are documented then you can never tell if its because its entirely obvious, or if the developer was simply too lazy - also consider that the purpose of a method may not be as obvious to others as it is to you.</p> <p>For example I don't bother to write documentation for event handlers (I used to but the comment was always exactly the same).</p>
    singulars
    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