Codigo Limpo Epub -
<h2>3. Comments: Don’t Compensate for Bad Code</h2> <p>The proper use of comments is to explain <em>why</em>, not <em>what</em>. Clear code needs few comments.</p>
<h3>Small! Really small</h3> <p>An entire function should rarely exceed 20 lines. If you need a comment to explain a block inside a function, extract that block into a new function.</p> codigo limpo epub
<h3>No side effects</h3> <p>A function named <code>checkPassword()</code> should not also initialize a session. Do one thing.</p> <h2>3
<h2>6. Error Handling: Separate Logic from Errors</h2> <p>Error handling is one thing. Your business logic is another. Don’t mix them.</p> Keep synchronized sections small.<
<h2>8. Unit Tests: First-Class Citizens</h2> <p>Tests must be kept as clean as production code. Follow the <strong>F.I.R.S.T.</strong> principles:</p> <ul> <li><strong>Fast</strong>: Run in milliseconds.</li> <li><strong>Independent</strong>: No test depends on another.</li> <li><strong>Repeatable</strong>: Same result in any environment.</li> <li><strong>Self-validating</strong>: Boolean output (pass/fail).</li> <li><strong>Timely</strong>: Written just before the production code (TDD).</li> </ul>
<h2>9. Concurrency: Keep It Simple</h2> <p>Concurrency adds complexity. Mitigate it:</p> <ul> <li>Keep synchronized sections small.</li> <li>Use immutable objects when possible.</li> <li>Document threading semantics.</li> <li>Test concurrency code aggressively with tools like ThreadSanitizer or JCStress.</li> </ul>