Files
2025-09-29 00:52:08 +02:00

86 lines
4.3 KiB
HTML
Executable File

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>CruiseControl.NET : Developer Guidelines</title>
<link rel="stylesheet" href="styles/site.css" type="text/css" />
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<table class="pagecontent" border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#ffffff">
<tr>
<td valign="top" class="pagebody">
<div class="pageheader">
<span class="pagetitle">
CruiseControl.NET : Developer Guidelines
</span>
</div>
<div class="pagesubheading">
This page last changed on Oct 18, 2004 by <font color="#0050B2">mroberts</font>.
</div>
<h3><a name="DeveloperGuidelines-DevelopmentPractices"></a>Development Practices</h3>
<ul>
<li>Test-first development. Code without unit tests will not be accepted.</li>
<li>Refactor mercilessly; however, notify the list before making large, broad-reaching refactorings.</li>
<li>Small methods (no more than 15 lines). Long methods will be collected and emailed to the list until a refactored solution is found.</li>
<li>Use guard clauses.</li>
<li>Write acceptance tests wherever possible.</li>
</ul>
<h3><a name="DeveloperGuidelines-TDDStandards%28UnitTestingandDesign%29"></a>TDD Standards (Unit Testing and Design)</h3>
<p><em>These standards are ideals, and not necessarily the current state of the code</em></p>
<ul>
<li>No unit-testing of private methods. TDD implies it is unnecessary.</li>
<li>Don't make methods public just so you can test them (see above)</li>
<li>Use Constructor Dependency Injection where possible.</li>
<li>Use Dynamic Mocks for Constructor Dependencies.</li>
<li>Interface-first design is preferred (i.e. all Constructor Dependencies should be interfaces)</li>
<li>DefaultXYZ as a name is a smell. What <b>exact</b> type of interface are you implementing?</li>
</ul>
<h3><a name="DeveloperGuidelines-CodingStandards"></a>Coding Standards</h3>
<ul>
<li>Respect the brace style. Curly braces at the start of the line:
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java"><span class="code-keyword">public</span> <span class="code-object">Class</span> Foo
{
<span class="code-keyword">public</span> Foo()
{
Console.WriteLine(<span class="code-quote">"Hello World!"</span>);
}
}</pre>
</div></div></li>
<li>Use C# naming conventions: methods, properties, classes should all start with upper-case letters.</li>
<li>Namespaces should be C# style. They should start with 'ThoughtWorks.CruiseControl.XYZ' where XYZ is the Visual Studio Project Name. Sub-namespaces should map to directories where source files are saved.</li>
<li>One file, one class &#8211; unless the inner class is private.</li>
<li>All member variables should be prefixed with an underscore (ie. _name).</li>
<li>The ternary operator is fine as long as the conditions are very simple.</li>
<li>Avoid assignment in conditionals &#8211; extract to method instead</li>
<li>Avoid magic numbers, use a nested enum or an inner class with public const members instead.</li>
<li>Use spaces after punctuation such as commas and spaces, in accordance with standard written grammar. For example, please include spaces after semi-colons, between equals signs and after keywords
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java"><span class="code-keyword">for</span> (<span class="code-object">int</span> i = 0; i &lt; array.Count; i++):</pre>
</div></div></li>
</ul>
</td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td height="12" background="http://confluence.public.thoughtworks.org//images/border/border_bottom.gif"><img src="images/border/spacer.gif" width="1" height="1" border="0"/></td>
</tr>
<tr>
<td align="center"><font color="grey">Document generated by Confluence on Mar 14, 2009 02:55</font></td>
</tr>
</table>
</body>
</html>