Auto-publish on Fri 26 Sep 15:56:57 BST 2025
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
||||
<head>
|
||||
<!-- 2025-08-28 Thu 17:45 -->
|
||||
<!-- 2025-09-26 Fri 15:56 -->
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Clean Code: Chapter 1 Notes</title>
|
||||
@@ -224,16 +224,16 @@
|
||||
<h2>Table of Contents</h2>
|
||||
<div id="text-table-of-contents" role="doc-toc">
|
||||
<ul>
|
||||
<li><a href="#orgab020fc">Chapter 1: Clean Code</a></li>
|
||||
<li><a href="#orge1ddfca">Chapter 1: Clean Code</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<p>
|
||||
Link to <a href="clean-code-chapter-2.html">Chapter 2</a>
|
||||
</p>
|
||||
<div id="outline-container-orgab020fc" class="outline-2">
|
||||
<h2 id="orgab020fc">Chapter 1: Clean Code</h2>
|
||||
<div class="outline-text-2" id="text-orgab020fc">
|
||||
<div id="outline-container-orge1ddfca" class="outline-2">
|
||||
<h2 id="orge1ddfca">Chapter 1: Clean Code</h2>
|
||||
<div class="outline-text-2" id="text-orge1ddfca">
|
||||
<p>
|
||||
Referenced Items:
|
||||
</p>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
||||
<head>
|
||||
<!-- 2025-08-28 Thu 17:45 -->
|
||||
<!-- 2025-09-26 Fri 15:56 -->
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Clean Code: Chapter 2 Notes</title>
|
||||
@@ -224,22 +224,22 @@
|
||||
<h2>Table of Contents</h2>
|
||||
<div id="text-table-of-contents" role="doc-toc">
|
||||
<ul>
|
||||
<li><a href="#org630654f">Chapter 2: Meaningful Names</a>
|
||||
<li><a href="#org4247d67">Chapter 2: Meaningful Names</a>
|
||||
<ul>
|
||||
<li><a href="#orgde95b75">Use intention revealing names:</a></li>
|
||||
<li><a href="#org7f8e08c">Avoid disinformation</a></li>
|
||||
<li><a href="#orgb008206">Make Meaningful Distinctions</a></li>
|
||||
<li><a href="#org9c76bf9">Use Pronouncable Names</a></li>
|
||||
<li><a href="#orgb099bcd">Use Searchable Names</a></li>
|
||||
<li><a href="#orgdaa212d">Avoid Encodings</a></li>
|
||||
<li><a href="#org381422a">Avoid Mental Mappings</a></li>
|
||||
<li><a href="#orga5b2d35">Class Names</a></li>
|
||||
<li><a href="#orga4f235d">Method Names</a></li>
|
||||
<li><a href="#org756720f">Don't be cute/Don't use puns</a></li>
|
||||
<li><a href="#org41cfca9">Pick one word per concept</a></li>
|
||||
<li><a href="#orgcb6db1f">Solution Domain Names and Problem Domain Names</a></li>
|
||||
<li><a href="#org0f79562">Add Meaningful Context</a></li>
|
||||
<li><a href="#orgb78d5d8">Don't add gratuitous context</a></li>
|
||||
<li><a href="#org378fb8a">Use intention revealing names:</a></li>
|
||||
<li><a href="#orga2bf5ed">Avoid disinformation</a></li>
|
||||
<li><a href="#orgf7ef497">Make Meaningful Distinctions</a></li>
|
||||
<li><a href="#org9e04aef">Use Pronouncable Names</a></li>
|
||||
<li><a href="#org1a97d2f">Use Searchable Names</a></li>
|
||||
<li><a href="#orgb39f99a">Avoid Encodings</a></li>
|
||||
<li><a href="#org23e8a38">Avoid Mental Mappings</a></li>
|
||||
<li><a href="#org69c81c7">Class Names</a></li>
|
||||
<li><a href="#orgbb957a7">Method Names</a></li>
|
||||
<li><a href="#orgc64f9d4">Don't be cute/Don't use puns</a></li>
|
||||
<li><a href="#orgee96b05">Pick one word per concept</a></li>
|
||||
<li><a href="#org866cbab">Solution Domain Names and Problem Domain Names</a></li>
|
||||
<li><a href="#org9d6e942">Add Meaningful Context</a></li>
|
||||
<li><a href="#org8ebf687">Don't add gratuitous context</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -248,13 +248,13 @@
|
||||
<p>
|
||||
Link to <a href="clean-code-chapter-1.html">Chapter 1</a> | Link to <a href="clean-code-chapter-3.html">Chapter 3</a>
|
||||
</p>
|
||||
<div id="outline-container-org630654f" class="outline-2">
|
||||
<h2 id="org630654f">Chapter 2: Meaningful Names</h2>
|
||||
<div class="outline-text-2" id="text-org630654f">
|
||||
<div id="outline-container-org4247d67" class="outline-2">
|
||||
<h2 id="org4247d67">Chapter 2: Meaningful Names</h2>
|
||||
<div class="outline-text-2" id="text-org4247d67">
|
||||
</div>
|
||||
<div id="outline-container-orgde95b75" class="outline-3">
|
||||
<h3 id="orgde95b75">Use intention revealing names:</h3>
|
||||
<div class="outline-text-3" id="text-orgde95b75">
|
||||
<div id="outline-container-org378fb8a" class="outline-3">
|
||||
<h3 id="org378fb8a">Use intention revealing names:</h3>
|
||||
<div class="outline-text-3" id="text-org378fb8a">
|
||||
<p>
|
||||
Names should reveal intent, there is no revelation in naming an integer <code>d</code>, intending it stands for days. Instead, you should use the following names:
|
||||
</p>
|
||||
@@ -267,17 +267,17 @@ Names should reveal intent, there is no revelation in naming an integer <code>d<
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org7f8e08c" class="outline-3">
|
||||
<h3 id="org7f8e08c">Avoid disinformation</h3>
|
||||
<div class="outline-text-3" id="text-org7f8e08c">
|
||||
<div id="outline-container-orga2bf5ed" class="outline-3">
|
||||
<h3 id="orga2bf5ed">Avoid disinformation</h3>
|
||||
<div class="outline-text-3" id="text-orga2bf5ed">
|
||||
<p>
|
||||
Don't postfix the word 'list' to the name 'accounts' unless it's actually a list. This is because the reader will <i>assume</i> the data type of accountsList is indeed a list, instead choose a name like <code>accountsGroup</code>.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-orgb008206" class="outline-3">
|
||||
<h3 id="orgb008206">Make Meaningful Distinctions</h3>
|
||||
<div class="outline-text-3" id="text-orgb008206">
|
||||
<div id="outline-container-orgf7ef497" class="outline-3">
|
||||
<h3 id="orgf7ef497">Make Meaningful Distinctions</h3>
|
||||
<div class="outline-text-3" id="text-orgf7ef497">
|
||||
<p>
|
||||
While it is possible to name by being disinformative, it is also possible to name being non informative. Consider:
|
||||
</p>
|
||||
@@ -302,18 +302,18 @@ Furthermore, noise words are redundant. We should never use the word <code>varia
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org9c76bf9" class="outline-3">
|
||||
<h3 id="org9c76bf9">Use Pronouncable Names</h3>
|
||||
<div class="outline-text-3" id="text-org9c76bf9">
|
||||
<div id="outline-container-org9e04aef" class="outline-3">
|
||||
<h3 id="org9e04aef">Use Pronouncable Names</h3>
|
||||
<div class="outline-text-3" id="text-org9e04aef">
|
||||
<p>
|
||||
This is quite straightforward. Do not use a name like <code>genymdhms</code> to refer to generation date, year, month, day, hour, minute,
|
||||
and second. Instead use <code>generationTimeStamp</code>.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-orgb099bcd" class="outline-3">
|
||||
<h3 id="orgb099bcd">Use Searchable Names</h3>
|
||||
<div class="outline-text-3" id="text-orgb099bcd">
|
||||
<div id="outline-container-org1a97d2f" class="outline-3">
|
||||
<h3 id="org1a97d2f">Use Searchable Names</h3>
|
||||
<div class="outline-text-3" id="text-org1a97d2f">
|
||||
<p>
|
||||
In modern IDE's, it is still quite difficult to search for single-lettered variables. The writer states a personal preference of using single-letter names only as local variables and inside short methods. The following principle is given:
|
||||
</p>
|
||||
@@ -323,42 +323,42 @@ In modern IDE's, it is still quite difficult to search for single-lettered varia
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-orgdaa212d" class="outline-3">
|
||||
<h3 id="orgdaa212d">Avoid Encodings</h3>
|
||||
<div class="outline-text-3" id="text-orgdaa212d">
|
||||
<div id="outline-container-orgb39f99a" class="outline-3">
|
||||
<h3 id="orgb39f99a">Avoid Encodings</h3>
|
||||
<div class="outline-text-3" id="text-orgb39f99a">
|
||||
<p>
|
||||
Don't prefix variables with letters like m_ as was done in the past. Do not type encode as well, an example of this is: <code>PhoneNumber phoneString;</code> we can see the reader being misled into thinking the phone number is a String.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org381422a" class="outline-3">
|
||||
<h3 id="org381422a">Avoid Mental Mappings</h3>
|
||||
<div class="outline-text-3" id="text-org381422a">
|
||||
<div id="outline-container-org23e8a38" class="outline-3">
|
||||
<h3 id="org23e8a38">Avoid Mental Mappings</h3>
|
||||
<div class="outline-text-3" id="text-org23e8a38">
|
||||
<p>
|
||||
Clarity is king, don't use a name for a variable that only you know what it stands for. For example: using the letter r as the lower-cased version of the url with the host and scheme
|
||||
removed. That's being smart, not professional.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-orga5b2d35" class="outline-3">
|
||||
<h3 id="orga5b2d35">Class Names</h3>
|
||||
<div class="outline-text-3" id="text-orga5b2d35">
|
||||
<div id="outline-container-org69c81c7" class="outline-3">
|
||||
<h3 id="org69c81c7">Class Names</h3>
|
||||
<div class="outline-text-3" id="text-org69c81c7">
|
||||
<p>
|
||||
<div class="epigraph"><blockquote>Classes and objects should have noun or noun phrase names like Customer, WikiPage, Account, and AddressParser. Avoid words like Manager, Processor, Data, or Info in the name of a class. A class name should not be a verb</blockquote></div>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-orga4f235d" class="outline-3">
|
||||
<h3 id="orga4f235d">Method Names</h3>
|
||||
<div class="outline-text-3" id="text-orga4f235d">
|
||||
<div id="outline-container-orgbb957a7" class="outline-3">
|
||||
<h3 id="orgbb957a7">Method Names</h3>
|
||||
<div class="outline-text-3" id="text-orgbb957a7">
|
||||
<p>
|
||||
Methods should have verb or verb phrase names.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org756720f" class="outline-3">
|
||||
<h3 id="org756720f">Don't be cute/Don't use puns</h3>
|
||||
<div class="outline-text-3" id="text-org756720f">
|
||||
<div id="outline-container-orgc64f9d4" class="outline-3">
|
||||
<h3 id="orgc64f9d4">Don't be cute/Don't use puns</h3>
|
||||
<div class="outline-text-3" id="text-orgc64f9d4">
|
||||
<p>
|
||||
Do not use names that are only understandable to people whom you share jokes etc with. Furthermore, do not use colloquialism and slang in names.
|
||||
</p>
|
||||
@@ -368,17 +368,17 @@ Do not use names that are only understandable to people whom you share jokes etc
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org41cfca9" class="outline-3">
|
||||
<h3 id="org41cfca9">Pick one word per concept</h3>
|
||||
<div class="outline-text-3" id="text-org41cfca9">
|
||||
<div id="outline-container-orgee96b05" class="outline-3">
|
||||
<h3 id="orgee96b05">Pick one word per concept</h3>
|
||||
<div class="outline-text-3" id="text-orgee96b05">
|
||||
<p>
|
||||
If you have multiple choices for naming a concept, use one and stick with it. For instance if your options are fetch, get and retrieve, use one and stick with it throughout.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-orgcb6db1f" class="outline-3">
|
||||
<h3 id="orgcb6db1f">Solution Domain Names and Problem Domain Names</h3>
|
||||
<div class="outline-text-3" id="text-orgcb6db1f">
|
||||
<div id="outline-container-org866cbab" class="outline-3">
|
||||
<h3 id="org866cbab">Solution Domain Names and Problem Domain Names</h3>
|
||||
<div class="outline-text-3" id="text-org866cbab">
|
||||
<p>
|
||||
Where possible use solution domain names, as the people that are going to be reading the code are programmers. Therefore, do not shy away from using CS terms, algorithm names, math names and so forth.
|
||||
</p>
|
||||
@@ -388,17 +388,17 @@ However when it is not possible to use solution domain names (in other words, wh
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org0f79562" class="outline-3">
|
||||
<h3 id="org0f79562">Add Meaningful Context</h3>
|
||||
<div class="outline-text-3" id="text-org0f79562">
|
||||
<div id="outline-container-org9d6e942" class="outline-3">
|
||||
<h3 id="org9d6e942">Add Meaningful Context</h3>
|
||||
<div class="outline-text-3" id="text-org9d6e942">
|
||||
<p>
|
||||
Enclose names with well-named classes, functions, or namespaces. When all else fails, then prefix with something that provides more context.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-orgb78d5d8" class="outline-3">
|
||||
<h3 id="orgb78d5d8">Don't add gratuitous context</h3>
|
||||
<div class="outline-text-3" id="text-orgb78d5d8">
|
||||
<div id="outline-container-org8ebf687" class="outline-3">
|
||||
<h3 id="org8ebf687">Don't add gratuitous context</h3>
|
||||
<div class="outline-text-3" id="text-org8ebf687">
|
||||
<p>
|
||||
Shorter names are better than longer ones, generally. This is so long as the context and intent is clear. Don't add redundant or irrelevant additions to the name in the for the sake of 'context'.
|
||||
</p>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
||||
<head>
|
||||
<!-- 2025-08-28 Thu 17:45 -->
|
||||
<!-- 2025-09-26 Fri 15:56 -->
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Clean Code: Chapter 3 Notes</title>
|
||||
@@ -224,15 +224,15 @@
|
||||
<h2>Table of Contents</h2>
|
||||
<div id="text-table-of-contents" role="doc-toc">
|
||||
<ul>
|
||||
<li><a href="#org0c5cb76">Chapter 3: Functions</a>
|
||||
<li><a href="#orgbe6ce1c">Chapter 3: Functions</a>
|
||||
<ul>
|
||||
<li><a href="#org4d1b5c4">Functions should be small</a></li>
|
||||
<li><a href="#org712e52f">Do One Thing & One Level of Abstraction</a></li>
|
||||
<li><a href="#orga673203">Switch Statements</a></li>
|
||||
<li><a href="#org26f4975">Use Descriptive Names</a></li>
|
||||
<li><a href="#org3c1e8f0">Function Arguments</a></li>
|
||||
<li><a href="#orgdfdb5df">Have No Side Effects</a></li>
|
||||
<li><a href="#orgb4f8a09">Error Handling</a></li>
|
||||
<li><a href="#org2c91360">Functions should be small</a></li>
|
||||
<li><a href="#orgc5ff09a">Do One Thing & One Level of Abstraction</a></li>
|
||||
<li><a href="#org046cc72">Switch Statements</a></li>
|
||||
<li><a href="#orgb5275a7">Use Descriptive Names</a></li>
|
||||
<li><a href="#orga9fd9ff">Function Arguments</a></li>
|
||||
<li><a href="#org7b91161">Have No Side Effects</a></li>
|
||||
<li><a href="#org00db549">Error Handling</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -241,13 +241,13 @@
|
||||
<p>
|
||||
Link to <a href="clean-code-chapter-2.html">Chapter 2</a> | Link to <a href="clean-code-chapter-4.html">Chapter 4</a>
|
||||
</p>
|
||||
<div id="outline-container-org0c5cb76" class="outline-2">
|
||||
<h2 id="org0c5cb76">Chapter 3: Functions</h2>
|
||||
<div class="outline-text-2" id="text-org0c5cb76">
|
||||
<div id="outline-container-orgbe6ce1c" class="outline-2">
|
||||
<h2 id="orgbe6ce1c">Chapter 3: Functions</h2>
|
||||
<div class="outline-text-2" id="text-orgbe6ce1c">
|
||||
</div>
|
||||
<div id="outline-container-org4d1b5c4" class="outline-3">
|
||||
<h3 id="org4d1b5c4">Functions should be small</h3>
|
||||
<div class="outline-text-3" id="text-org4d1b5c4">
|
||||
<div id="outline-container-org2c91360" class="outline-3">
|
||||
<h3 id="org2c91360">Functions should be small</h3>
|
||||
<div class="outline-text-3" id="text-org2c91360">
|
||||
<p>
|
||||
Functions should be extremely short—ideally just a few lines, so they remain easy to understand and maintain.
|
||||
</p>
|
||||
@@ -269,9 +269,9 @@ Large functions hide complexity and mix abstraction levels, making errors and du
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org712e52f" class="outline-3">
|
||||
<h3 id="org712e52f">Do One Thing & One Level of Abstraction</h3>
|
||||
<div class="outline-text-3" id="text-org712e52f">
|
||||
<div id="outline-container-orgc5ff09a" class="outline-3">
|
||||
<h3 id="orgc5ff09a">Do One Thing & One Level of Abstraction</h3>
|
||||
<div class="outline-text-3" id="text-orgc5ff09a">
|
||||
<p>
|
||||
A function should do exactly one conceptual task, and all its statements should exist at the same abstraction level.
|
||||
</p>
|
||||
@@ -293,9 +293,9 @@ Functions that “do one thing” cannot be logically split into sections such a
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-orga673203" class="outline-3">
|
||||
<h3 id="orga673203">Switch Statements</h3>
|
||||
<div class="outline-text-3" id="text-orga673203">
|
||||
<div id="outline-container-org046cc72" class="outline-3">
|
||||
<h3 id="org046cc72">Switch Statements</h3>
|
||||
<div class="outline-text-3" id="text-org046cc72">
|
||||
<p>
|
||||
Switch statements naturally violate “do one thing” by handling multiple cases; they also grow in size over time.
|
||||
</p>
|
||||
@@ -350,9 +350,9 @@ Example:
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org26f4975" class="outline-3">
|
||||
<h3 id="org26f4975">Use Descriptive Names</h3>
|
||||
<div class="outline-text-3" id="text-org26f4975">
|
||||
<div id="outline-container-orgb5275a7" class="outline-3">
|
||||
<h3 id="orgb5275a7">Use Descriptive Names</h3>
|
||||
<div class="outline-text-3" id="text-orgb5275a7">
|
||||
<p>
|
||||
A function’s name should clearly state its purpose. Long, descriptive names beat short, cryptic ones.
|
||||
</p>
|
||||
@@ -374,9 +374,9 @@ IDE refactoring tools make renaming safe, encouraging experimentation.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org3c1e8f0" class="outline-3">
|
||||
<h3 id="org3c1e8f0">Function Arguments</h3>
|
||||
<div class="outline-text-3" id="text-org3c1e8f0">
|
||||
<div id="outline-container-orga9fd9ff" class="outline-3">
|
||||
<h3 id="orga9fd9ff">Function Arguments</h3>
|
||||
<div class="outline-text-3" id="text-orga9fd9ff">
|
||||
<p>
|
||||
<div class="epigraph"><blockquote>The ideal number of arguments for a function is zero (niladic). Next comes one (monadic), followed closely by two (dyadic). Three arguments (triadic) should be avoided where possible. More than three (polyadic) requires very special justification—and then shouldn’t be used anyway.</blockquote></div>
|
||||
</p>
|
||||
@@ -402,9 +402,9 @@ Match function/argument names in verb–noun or keyword style (e.g., <code>write
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-orgdfdb5df" class="outline-3">
|
||||
<h3 id="orgdfdb5df">Have No Side Effects</h3>
|
||||
<div class="outline-text-3" id="text-orgdfdb5df">
|
||||
<div id="outline-container-org7b91161" class="outline-3">
|
||||
<h3 id="org7b91161">Have No Side Effects</h3>
|
||||
<div class="outline-text-3" id="text-org7b91161">
|
||||
<p>
|
||||
A function should do only what its name promises. Hidden state changes are misleading and dangerous.
|
||||
</p>
|
||||
@@ -426,9 +426,9 @@ Functions that modify state and return information often cause confusion and sho
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-orgb4f8a09" class="outline-3">
|
||||
<h3 id="orgb4f8a09">Error Handling</h3>
|
||||
<div class="outline-text-3" id="text-orgb4f8a09">
|
||||
<div id="outline-container-org00db549" class="outline-3">
|
||||
<h3 id="org00db549">Error Handling</h3>
|
||||
<div class="outline-text-3" id="text-org00db549">
|
||||
<p>
|
||||
Error handling is a single responsibility—separate it from normal logic to keep both paths clear.
|
||||
</p>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
||||
<head>
|
||||
<!-- 2025-08-28 Thu 17:45 -->
|
||||
<!-- 2025-09-26 Fri 15:56 -->
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Clean Code: Chapter 4 Notes</title>
|
||||
@@ -224,34 +224,34 @@
|
||||
<h2>Table of Contents</h2>
|
||||
<div id="text-table-of-contents" role="doc-toc">
|
||||
<ul>
|
||||
<li><a href="#orgf38a65c">Chapter 4: Comments</a>
|
||||
<li><a href="#org3b3a86a">Chapter 4: Comments</a>
|
||||
<ul>
|
||||
<li><a href="#orgccbc8a0">Comments Do Not Make Up for Bad Code</a></li>
|
||||
<li><a href="#orgf7cdf31">Good Comments</a>
|
||||
<li><a href="#org563b20a">Comments Do Not Make Up for Bad Code</a></li>
|
||||
<li><a href="#orgbb15258">Good Comments</a>
|
||||
<ul>
|
||||
<li><a href="#org9362690">Legal Comments</a></li>
|
||||
<li><a href="#orgea06608">Informative Comments</a></li>
|
||||
<li><a href="#org9a8cff9">Explanation of Intent</a></li>
|
||||
<li><a href="#org756e85b">Clarification</a></li>
|
||||
<li><a href="#orge9e3aea">Warning of Consequences</a></li>
|
||||
<li><a href="#orgda7a8c2"><span class="todo TODO">TODO</span> Comments</a></li>
|
||||
<li><a href="#org7ab6062">Amplification</a></li>
|
||||
<li><a href="#org4e714d5">Javadocs in Public APIs</a></li>
|
||||
<li><a href="#orgc8daf95">Legal Comments</a></li>
|
||||
<li><a href="#org5f86e2c">Informative Comments</a></li>
|
||||
<li><a href="#org9c9a43a">Explanation of Intent</a></li>
|
||||
<li><a href="#org132954b">Clarification</a></li>
|
||||
<li><a href="#org2bc9356">Warning of Consequences</a></li>
|
||||
<li><a href="#org29e7534"><span class="todo TODO">TODO</span> Comments</a></li>
|
||||
<li><a href="#org8f96c61">Amplification</a></li>
|
||||
<li><a href="#orgf0eacd6">Javadocs in Public APIs</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#orgad7568e">Bad Comments</a>
|
||||
<li><a href="#orgeceeef2">Bad Comments</a>
|
||||
<ul>
|
||||
<li><a href="#org4e4984e">Don’t Use a Comment When You Can Use a Function or Variable</a></li>
|
||||
<li><a href="#orgaf4e48a">Position Markers</a></li>
|
||||
<li><a href="#orgb51d8f6">Closing Brace Comments</a></li>
|
||||
<li><a href="#org45f7fed">Attributions and Bylines</a></li>
|
||||
<li><a href="#orgd72549e">Commented Out Code</a></li>
|
||||
<li><a href="#orga4d406b">HTML Comments</a></li>
|
||||
<li><a href="#org191c38a">Nonlocal Information</a></li>
|
||||
<li><a href="#org66a46c7">Too Much Information</a></li>
|
||||
<li><a href="#org1de4858">Inobvious Connection</a></li>
|
||||
<li><a href="#orgec05bc1">Function Headers</a></li>
|
||||
<li><a href="#org9f353fd">Javadocs in Nonpublic Code</a></li>
|
||||
<li><a href="#org8948eeb">Don’t Use a Comment When You Can Use a Function or Variable</a></li>
|
||||
<li><a href="#org9dd57c3">Position Markers</a></li>
|
||||
<li><a href="#org27ce2f1">Closing Brace Comments</a></li>
|
||||
<li><a href="#orgec579fa">Attributions and Bylines</a></li>
|
||||
<li><a href="#org5ae47be">Commented Out Code</a></li>
|
||||
<li><a href="#orgfe581e3">HTML Comments</a></li>
|
||||
<li><a href="#org458bb98">Nonlocal Information</a></li>
|
||||
<li><a href="#org6d8a526">Too Much Information</a></li>
|
||||
<li><a href="#org99e4520">Inobvious Connection</a></li>
|
||||
<li><a href="#org856f330">Function Headers</a></li>
|
||||
<li><a href="#org080d921">Javadocs in Nonpublic Code</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -262,9 +262,9 @@
|
||||
<p>
|
||||
Link to <a href="clean-code-chapter-3.html">Chapter 3</a> | Link to <a href="clean-code-chapter-5.html">Chapter 5</a>
|
||||
</p>
|
||||
<div id="outline-container-orgf38a65c" class="outline-2">
|
||||
<h2 id="orgf38a65c">Chapter 4: Comments</h2>
|
||||
<div class="outline-text-2" id="text-orgf38a65c">
|
||||
<div id="outline-container-org3b3a86a" class="outline-2">
|
||||
<h2 id="org3b3a86a">Chapter 4: Comments</h2>
|
||||
<div class="outline-text-2" id="text-org3b3a86a">
|
||||
<p>
|
||||
Comments are a necessary evil—they exist because code fails to express intent clearly.
|
||||
</p>
|
||||
@@ -281,9 +281,9 @@ Strive to write code that explains itself; comments should be minimised.
|
||||
Truth is always in the code, not in the comments.
|
||||
</p>
|
||||
</div>
|
||||
<div id="outline-container-orgccbc8a0" class="outline-3">
|
||||
<h3 id="orgccbc8a0">Comments Do Not Make Up for Bad Code</h3>
|
||||
<div class="outline-text-3" id="text-orgccbc8a0">
|
||||
<div id="outline-container-org563b20a" class="outline-3">
|
||||
<h3 id="org563b20a">Comments Do Not Make Up for Bad Code</h3>
|
||||
<div class="outline-text-3" id="text-org563b20a">
|
||||
<p>
|
||||
Don’t use comments to excuse messy, unclear code. Clean the code instead.
|
||||
</p>
|
||||
@@ -304,16 +304,16 @@ Clear, expressive code with few comments > cluttered code with many comments.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-orgf7cdf31" class="outline-3">
|
||||
<h3 id="orgf7cdf31">Good Comments</h3>
|
||||
<div class="outline-text-3" id="text-orgf7cdf31">
|
||||
<div id="outline-container-orgbb15258" class="outline-3">
|
||||
<h3 id="orgbb15258">Good Comments</h3>
|
||||
<div class="outline-text-3" id="text-orgbb15258">
|
||||
<p>
|
||||
Only write them when unavoidable. Such as in the following instances:
|
||||
</p>
|
||||
</div>
|
||||
<div id="outline-container-org9362690" class="outline-4">
|
||||
<h4 id="org9362690">Legal Comments</h4>
|
||||
<div class="outline-text-4" id="text-org9362690">
|
||||
<div id="outline-container-orgc8daf95" class="outline-4">
|
||||
<h4 id="orgc8daf95">Legal Comments</h4>
|
||||
<div class="outline-text-4" id="text-orgc8daf95">
|
||||
<p>
|
||||
Sometimes required for copyright/licensing.
|
||||
</p>
|
||||
@@ -323,9 +323,9 @@ Keep them short; refer to standard licenses rather than embedding full legal tex
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-orgea06608" class="outline-4">
|
||||
<h4 id="orgea06608">Informative Comments</h4>
|
||||
<div class="outline-text-4" id="text-orgea06608">
|
||||
<div id="outline-container-org5f86e2c" class="outline-4">
|
||||
<h4 id="org5f86e2c">Informative Comments</h4>
|
||||
<div class="outline-text-4" id="text-org5f86e2c">
|
||||
<p>
|
||||
Explain return values, formats, or patterns.
|
||||
</p>
|
||||
@@ -343,9 +343,9 @@ Prefer naming/structuring code to make such comments unnecessary.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org9a8cff9" class="outline-4">
|
||||
<h4 id="org9a8cff9">Explanation of Intent</h4>
|
||||
<div class="outline-text-4" id="text-org9a8cff9">
|
||||
<div id="outline-container-org9c9a43a" class="outline-4">
|
||||
<h4 id="org9c9a43a">Explanation of Intent</h4>
|
||||
<div class="outline-text-4" id="text-org9c9a43a">
|
||||
<p>
|
||||
Describe why a certain approach was chosen.
|
||||
</p>
|
||||
@@ -371,9 +371,9 @@ Helps future maintainers understand reasoning behind code.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org756e85b" class="outline-4">
|
||||
<h4 id="org756e85b">Clarification</h4>
|
||||
<div class="outline-text-4" id="text-org756e85b">
|
||||
<div id="outline-container-org132954b" class="outline-4">
|
||||
<h4 id="org132954b">Clarification</h4>
|
||||
<div class="outline-text-4" id="text-org132954b">
|
||||
<p>
|
||||
Translate obscure values into readable terms.
|
||||
</p>
|
||||
@@ -383,9 +383,9 @@ Useful when working with unchangeable APIs/libraries, but risky if incorrect.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-orge9e3aea" class="outline-4">
|
||||
<h4 id="orge9e3aea">Warning of Consequences</h4>
|
||||
<div class="outline-text-4" id="text-orge9e3aea">
|
||||
<div id="outline-container-org2bc9356" class="outline-4">
|
||||
<h4 id="org2bc9356">Warning of Consequences</h4>
|
||||
<div class="outline-text-4" id="text-org2bc9356">
|
||||
<p>
|
||||
Alert others about performance, thread-safety, or side effects.
|
||||
</p>
|
||||
@@ -399,9 +399,9 @@ For example, in code you can say:
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-orgda7a8c2" class="outline-4">
|
||||
<h4 id="orgda7a8c2"><span class="todo TODO">TODO</span> Comments</h4>
|
||||
<div class="outline-text-4" id="text-orgda7a8c2">
|
||||
<div id="outline-container-org29e7534" class="outline-4">
|
||||
<h4 id="org29e7534"><span class="todo TODO">TODO</span> Comments</h4>
|
||||
<div class="outline-text-4" id="text-org29e7534">
|
||||
<p>
|
||||
Mark incomplete work or planned improvements.
|
||||
</p>
|
||||
@@ -411,9 +411,9 @@ Should be reviewed regularly; not an excuse for bad code.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org7ab6062" class="outline-4">
|
||||
<h4 id="org7ab6062">Amplification</h4>
|
||||
<div class="outline-text-4" id="text-org7ab6062">
|
||||
<div id="outline-container-org8f96c61" class="outline-4">
|
||||
<h4 id="org8f96c61">Amplification</h4>
|
||||
<div class="outline-text-4" id="text-org8f96c61">
|
||||
<p>
|
||||
Highlight the importance of seemingly small details.
|
||||
</p>
|
||||
@@ -423,9 +423,9 @@ Highlight the importance of seemingly small details.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org4e714d5" class="outline-4">
|
||||
<h4 id="org4e714d5">Javadocs in Public APIs</h4>
|
||||
<div class="outline-text-4" id="text-org4e714d5">
|
||||
<div id="outline-container-orgf0eacd6" class="outline-4">
|
||||
<h4 id="orgf0eacd6">Javadocs in Public APIs</h4>
|
||||
<div class="outline-text-4" id="text-orgf0eacd6">
|
||||
<p>
|
||||
Public APIs should have clear documentation.
|
||||
</p>
|
||||
@@ -436,9 +436,9 @@ Javadocs can also mislead. Keep them accurate and up-to-date.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-orgad7568e" class="outline-3">
|
||||
<h3 id="orgad7568e">Bad Comments</h3>
|
||||
<div class="outline-text-3" id="text-orgad7568e">
|
||||
<div id="outline-container-orgeceeef2" class="outline-3">
|
||||
<h3 id="orgeceeef2">Bad Comments</h3>
|
||||
<div class="outline-text-3" id="text-orgeceeef2">
|
||||
<ul class="org-ul">
|
||||
<li>Don't place a comment just because you feel like it.</li>
|
||||
<li>Remove redundant comments.</li>
|
||||
@@ -448,9 +448,9 @@ Javadocs can also mislead. Keep them accurate and up-to-date.
|
||||
<li>Remove noise comments.</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="outline-container-org4e4984e" class="outline-4">
|
||||
<h4 id="org4e4984e">Don’t Use a Comment When You Can Use a Function or Variable</h4>
|
||||
<div class="outline-text-4" id="text-org4e4984e">
|
||||
<div id="outline-container-org8948eeb" class="outline-4">
|
||||
<h4 id="org8948eeb">Don’t Use a Comment When You Can Use a Function or Variable</h4>
|
||||
<div class="outline-text-4" id="text-org8948eeb">
|
||||
<p>
|
||||
Replace explanatory comments with expressive variable or function names.
|
||||
</p>
|
||||
@@ -460,9 +460,9 @@ Refactor code to remove comment redundancy.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-orgaf4e48a" class="outline-4">
|
||||
<h4 id="orgaf4e48a">Position Markers</h4>
|
||||
<div class="outline-text-4" id="text-orgaf4e48a">
|
||||
<div id="outline-container-org9dd57c3" class="outline-4">
|
||||
<h4 id="org9dd57c3">Position Markers</h4>
|
||||
<div class="outline-text-4" id="text-org9dd57c3">
|
||||
<p>
|
||||
Avoid decorative banners like <code>// Actions ///////////////////////</code>, they add clutter.
|
||||
</p>
|
||||
@@ -476,9 +476,9 @@ Overuse makes them blend into background noise.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-orgb51d8f6" class="outline-4">
|
||||
<h4 id="orgb51d8f6">Closing Brace Comments</h4>
|
||||
<div class="outline-text-4" id="text-orgb51d8f6">
|
||||
<div id="outline-container-org27ce2f1" class="outline-4">
|
||||
<h4 id="org27ce2f1">Closing Brace Comments</h4>
|
||||
<div class="outline-text-4" id="text-org27ce2f1">
|
||||
<p>
|
||||
Comments on closing braces (} // while) are unnecessary for small, well structured functions.
|
||||
</p>
|
||||
@@ -488,9 +488,9 @@ Prefer short, clear functions over brace markers.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org45f7fed" class="outline-4">
|
||||
<h4 id="org45f7fed">Attributions and Bylines</h4>
|
||||
<div class="outline-text-4" id="text-org45f7fed">
|
||||
<div id="outline-container-orgec579fa" class="outline-4">
|
||||
<h4 id="orgec579fa">Attributions and Bylines</h4>
|
||||
<div class="outline-text-4" id="text-orgec579fa">
|
||||
<p>
|
||||
Don’t add personal tags like <code>/* Added by Rick */</code>, use version control for authorship history.
|
||||
</p>
|
||||
@@ -500,9 +500,9 @@ Such comments become outdated and irrelevant over time.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-orgd72549e" class="outline-4">
|
||||
<h4 id="orgd72549e">Commented Out Code</h4>
|
||||
<div class="outline-text-4" id="text-orgd72549e">
|
||||
<div id="outline-container-org5ae47be" class="outline-4">
|
||||
<h4 id="org5ae47be">Commented Out Code</h4>
|
||||
<div class="outline-text-4" id="text-org5ae47be">
|
||||
<p>
|
||||
Never keep old code commented out; delete it and rely on version control history.
|
||||
</p>
|
||||
@@ -521,9 +521,9 @@ Commented-out code adds clutter and confuses future maintainers.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-orga4d406b" class="outline-4">
|
||||
<h4 id="orga4d406b">HTML Comments</h4>
|
||||
<div class="outline-text-4" id="text-orga4d406b">
|
||||
<div id="outline-container-orgfe581e3" class="outline-4">
|
||||
<h4 id="orgfe581e3">HTML Comments</h4>
|
||||
<div class="outline-text-4" id="text-orgfe581e3">
|
||||
<p>
|
||||
Avoid HTML markup inside code comments, it makes them harder to read in the editor.
|
||||
</p>
|
||||
@@ -533,9 +533,9 @@ Let documentation tools (like Javadoc) handle formatting.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org191c38a" class="outline-4">
|
||||
<h4 id="org191c38a">Nonlocal Information</h4>
|
||||
<div class="outline-text-4" id="text-org191c38a">
|
||||
<div id="outline-container-org458bb98" class="outline-4">
|
||||
<h4 id="org458bb98">Nonlocal Information</h4>
|
||||
<div class="outline-text-4" id="text-org458bb98">
|
||||
<p>
|
||||
Comments should describe nearby code only, not unrelated parts of the system.
|
||||
</p>
|
||||
@@ -545,9 +545,9 @@ Avoid embedding global/system details that the function can’t control.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org66a46c7" class="outline-4">
|
||||
<h4 id="org66a46c7">Too Much Information</h4>
|
||||
<div class="outline-text-4" id="text-org66a46c7">
|
||||
<div id="outline-container-org6d8a526" class="outline-4">
|
||||
<h4 id="org6d8a526">Too Much Information</h4>
|
||||
<div class="outline-text-4" id="text-org6d8a526">
|
||||
<p>
|
||||
Avoid long, unnecessary historical or technical explanations.
|
||||
</p>
|
||||
@@ -557,9 +557,9 @@ Keep only relevant context (e.g., “RFC 2045” reference is fine, not the full
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org1de4858" class="outline-4">
|
||||
<h4 id="org1de4858">Inobvious Connection</h4>
|
||||
<div class="outline-text-4" id="text-org1de4858">
|
||||
<div id="outline-container-org99e4520" class="outline-4">
|
||||
<h4 id="org99e4520">Inobvious Connection</h4>
|
||||
<div class="outline-text-4" id="text-org99e4520">
|
||||
<p>
|
||||
Ensure the relationship between comment and code is clear.
|
||||
</p>
|
||||
@@ -577,9 +577,9 @@ Don’t make readers guess what part of the code the comment refers to.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-orgec05bc1" class="outline-4">
|
||||
<h4 id="orgec05bc1">Function Headers</h4>
|
||||
<div class="outline-text-4" id="text-orgec05bc1">
|
||||
<div id="outline-container-org856f330" class="outline-4">
|
||||
<h4 id="org856f330">Function Headers</h4>
|
||||
<div class="outline-text-4" id="text-org856f330">
|
||||
<p>
|
||||
Short, single purpose functions with good names don’t need header comments.
|
||||
</p>
|
||||
@@ -589,9 +589,9 @@ Let the function name explain the purpose.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org9f353fd" class="outline-4">
|
||||
<h4 id="org9f353fd">Javadocs in Nonpublic Code</h4>
|
||||
<div class="outline-text-4" id="text-org9f353fd">
|
||||
<div id="outline-container-org080d921" class="outline-4">
|
||||
<h4 id="org080d921">Javadocs in Nonpublic Code</h4>
|
||||
<div class="outline-text-4" id="text-org080d921">
|
||||
<p>
|
||||
Javadocs are useful for public APIs, but excessive formality in internal code is just noise.
|
||||
</p>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
||||
<head>
|
||||
<!-- 2025-08-28 Thu 17:45 -->
|
||||
<!-- 2025-09-26 Fri 15:56 -->
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Clean Code: Chapter 5 Notes</title>
|
||||
@@ -224,27 +224,27 @@
|
||||
<h2>Table of Contents</h2>
|
||||
<div id="text-table-of-contents" role="doc-toc">
|
||||
<ul>
|
||||
<li><a href="#orgd0110e3">Chapter 5: Formatting</a>
|
||||
<li><a href="#orgef44787">Chapter 5: Formatting</a>
|
||||
<ul>
|
||||
<li><a href="#org3fcbb7b">Vertical Formatting</a>
|
||||
<li><a href="#orgadece72">Vertical Formatting</a>
|
||||
<ul>
|
||||
<li><a href="#org112c082">Vertical Density</a></li>
|
||||
<li><a href="#org5960270">Vertical Distance</a></li>
|
||||
<li><a href="#org298ae14">Conceptual Affinity</a></li>
|
||||
<li><a href="#org7badd36">Vertical Ordering</a></li>
|
||||
<li><a href="#org2ec4ff8">Summary - vertical</a></li>
|
||||
<li><a href="#org1df6015">Vertical Density</a></li>
|
||||
<li><a href="#org7162958">Vertical Distance</a></li>
|
||||
<li><a href="#orgb180e7e">Conceptual Affinity</a></li>
|
||||
<li><a href="#orge6bdd5c">Vertical Ordering</a></li>
|
||||
<li><a href="#org0ca1180">Summary - vertical</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#orge6c1094">Horizontal Formatting</a>
|
||||
<li><a href="#orga16627a">Horizontal Formatting</a>
|
||||
<ul>
|
||||
<li><a href="#orgfc5c376">Horizontal Openness and Density</a></li>
|
||||
<li><a href="#org1f66087">Horizontal Alignment</a></li>
|
||||
<li><a href="#org47bba53">Indentation</a></li>
|
||||
<li><a href="#orgd5dbd58">Dummy Scopes</a></li>
|
||||
<li><a href="#orgaa2edbb">Horizontal Openness and Density</a></li>
|
||||
<li><a href="#orga7436cc">Horizontal Alignment</a></li>
|
||||
<li><a href="#org1c3761d">Indentation</a></li>
|
||||
<li><a href="#org1beb2d2">Dummy Scopes</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#orgd230786">Team Rules</a></li>
|
||||
<li><a href="#orgfb1d75c">Uncle Bob’s Formatting Rules (Example in CodeAnalyzer.java)</a></li>
|
||||
<li><a href="#org2c3d751">Team Rules</a></li>
|
||||
<li><a href="#orgc460a51">Uncle Bob’s Formatting Rules (Example in CodeAnalyzer.java)</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -253,21 +253,21 @@
|
||||
<p>
|
||||
Link to <a href="clean-code-chapter-4.html">Chapter 4</a> | Link to <a href="clean-code-chapter-6.html">Chapter 6</a>
|
||||
</p>
|
||||
<div id="outline-container-orgd0110e3" class="outline-2">
|
||||
<h2 id="orgd0110e3">Chapter 5: Formatting</h2>
|
||||
<div class="outline-text-2" id="text-orgd0110e3">
|
||||
<div id="outline-container-orgef44787" class="outline-2">
|
||||
<h2 id="orgef44787">Chapter 5: Formatting</h2>
|
||||
<div class="outline-text-2" id="text-orgef44787">
|
||||
</div>
|
||||
<div id="outline-container-org3fcbb7b" class="outline-3">
|
||||
<h3 id="org3fcbb7b">Vertical Formatting</h3>
|
||||
<div class="outline-text-3" id="text-org3fcbb7b">
|
||||
<div id="outline-container-orgadece72" class="outline-3">
|
||||
<h3 id="orgadece72">Vertical Formatting</h3>
|
||||
<div class="outline-text-3" id="text-orgadece72">
|
||||
<ul class="org-ul">
|
||||
<li>Vertical openness (blank lines) separates concepts and improves readability.</li>
|
||||
<li>Too much density makes code look like a muddle and harder to scan.</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="outline-container-org112c082" class="outline-4">
|
||||
<h4 id="org112c082">Vertical Density</h4>
|
||||
<div class="outline-text-4" id="text-org112c082">
|
||||
<div id="outline-container-org1df6015" class="outline-4">
|
||||
<h4 id="org1df6015">Vertical Density</h4>
|
||||
<div class="outline-text-4" id="text-org1df6015">
|
||||
<ul class="org-ul">
|
||||
<li>Tightly related lines should appear vertically dense.</li>
|
||||
<li>Avoid useless comments that interrupt association.</li>
|
||||
@@ -293,9 +293,9 @@ Link to <a href="clean-code-chapter-4.html">Chapter 4</a> | Link to <a href="cle
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org5960270" class="outline-4">
|
||||
<h4 id="org5960270">Vertical Distance</h4>
|
||||
<div class="outline-text-4" id="text-org5960270">
|
||||
<div id="outline-container-org7162958" class="outline-4">
|
||||
<h4 id="org7162958">Vertical Distance</h4>
|
||||
<div class="outline-text-4" id="text-org7162958">
|
||||
<ul class="org-ul">
|
||||
<li>Related concepts should be kept close together to reduce scrolling and searching.</li>
|
||||
<li>Local variables → as close to use as possible, usually at top of function.</li>
|
||||
@@ -325,9 +325,9 @@ Link to <a href="clean-code-chapter-4.html">Chapter 4</a> | Link to <a href="cle
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org298ae14" class="outline-4">
|
||||
<h4 id="org298ae14">Conceptual Affinity</h4>
|
||||
<div class="outline-text-4" id="text-org298ae14">
|
||||
<div id="outline-container-orgb180e7e" class="outline-4">
|
||||
<h4 id="orgb180e7e">Conceptual Affinity</h4>
|
||||
<div class="outline-text-4" id="text-orgb180e7e">
|
||||
<ul class="org-ul">
|
||||
<li>Group functions with similar naming or shared purpose.</li>
|
||||
<li>Example (JUnit assert methods):</li>
|
||||
@@ -341,9 +341,9 @@ Link to <a href="clean-code-chapter-4.html">Chapter 4</a> | Link to <a href="cle
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org7badd36" class="outline-4">
|
||||
<h4 id="org7badd36">Vertical Ordering</h4>
|
||||
<div class="outline-text-4" id="text-org7badd36">
|
||||
<div id="outline-container-orge6bdd5c" class="outline-4">
|
||||
<h4 id="orge6bdd5c">Vertical Ordering</h4>
|
||||
<div class="outline-text-4" id="text-orge6bdd5c">
|
||||
<ul class="org-ul">
|
||||
<li>Organise code top down:
|
||||
<ul class="org-ul">
|
||||
@@ -355,9 +355,9 @@ Link to <a href="clean-code-chapter-4.html">Chapter 4</a> | Link to <a href="cle
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org2ec4ff8" class="outline-4">
|
||||
<h4 id="org2ec4ff8">Summary - vertical</h4>
|
||||
<div class="outline-text-4" id="text-org2ec4ff8">
|
||||
<div id="outline-container-org0ca1180" class="outline-4">
|
||||
<h4 id="org0ca1180">Summary - vertical</h4>
|
||||
<div class="outline-text-4" id="text-org0ca1180">
|
||||
<ul class="org-ul">
|
||||
<li>Use vertical openness to separate concepts.</li>
|
||||
<li>Use vertical density to group related ones.</li>
|
||||
@@ -367,9 +367,9 @@ Link to <a href="clean-code-chapter-4.html">Chapter 4</a> | Link to <a href="cle
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-orge6c1094" class="outline-3">
|
||||
<h3 id="orge6c1094">Horizontal Formatting</h3>
|
||||
<div class="outline-text-3" id="text-orge6c1094">
|
||||
<div id="outline-container-orga16627a" class="outline-3">
|
||||
<h3 id="orga16627a">Horizontal Formatting</h3>
|
||||
<div class="outline-text-3" id="text-orga16627a">
|
||||
<p>
|
||||
Keep lines short. Most professional code naturally stays within ~45 characters, with ~80 as an upper bound. Lines beyond 100–120 characters are generally careless.
|
||||
</p>
|
||||
@@ -391,9 +391,9 @@ Example limit guideline:
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-orgfc5c376" class="outline-4">
|
||||
<h4 id="orgfc5c376">Horizontal Openness and Density</h4>
|
||||
<div class="outline-text-4" id="text-orgfc5c376">
|
||||
<div id="outline-container-orgaa2edbb" class="outline-4">
|
||||
<h4 id="orgaa2edbb">Horizontal Openness and Density</h4>
|
||||
<div class="outline-text-4" id="text-orgaa2edbb">
|
||||
<p>
|
||||
Use spaces to separate low-precedence operators (e.g., +, -, =) and improve readability.
|
||||
</p>
|
||||
@@ -416,9 +416,9 @@ Separate arguments with spaces after commas to show distinct parameters.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org1f66087" class="outline-4">
|
||||
<h4 id="org1f66087">Horizontal Alignment</h4>
|
||||
<div class="outline-text-4" id="text-org1f66087">
|
||||
<div id="outline-container-orga7436cc" class="outline-4">
|
||||
<h4 id="orga7436cc">Horizontal Alignment</h4>
|
||||
<div class="outline-text-4" id="text-orga7436cc">
|
||||
<p>
|
||||
Avoid aligning variable declarations or assignments in columns, it draws the eye to the wrong place.
|
||||
</p>
|
||||
@@ -446,9 +446,9 @@ Example (preferred unaligned):
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org47bba53" class="outline-4">
|
||||
<h4 id="org47bba53">Indentation</h4>
|
||||
<div class="outline-text-4" id="text-org47bba53">
|
||||
<div id="outline-container-org1c3761d" class="outline-4">
|
||||
<h4 id="org1c3761d">Indentation</h4>
|
||||
<div class="outline-text-4" id="text-org1c3761d">
|
||||
<p>
|
||||
Indent according to scope hierarchy:
|
||||
</p>
|
||||
@@ -478,9 +478,9 @@ Avoid collapsing scopes onto one line, always use braces and proper indenting.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-orgd5dbd58" class="outline-4">
|
||||
<h4 id="orgd5dbd58">Dummy Scopes</h4>
|
||||
<div class="outline-text-4" id="text-orgd5dbd58">
|
||||
<div id="outline-container-org1beb2d2" class="outline-4">
|
||||
<h4 id="org1beb2d2">Dummy Scopes</h4>
|
||||
<div class="outline-text-4" id="text-org1beb2d2">
|
||||
<p>
|
||||
Avoid dummy bodies in loops (e.g., empty while or for loops).
|
||||
</p>
|
||||
@@ -497,9 +497,9 @@ If unavoidable, place semicolon on its own indented line to make it visible.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-orgd230786" class="outline-3">
|
||||
<h3 id="orgd230786">Team Rules</h3>
|
||||
<div class="outline-text-3" id="text-orgd230786">
|
||||
<div id="outline-container-org2c3d751" class="outline-3">
|
||||
<h3 id="org2c3d751">Team Rules</h3>
|
||||
<div class="outline-text-3" id="text-org2c3d751">
|
||||
<p>
|
||||
Teams must agree on a single formatting style for consistency.
|
||||
</p>
|
||||
@@ -513,9 +513,9 @@ Consistent formatting builds trust and reduces mental load for readers.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-orgfb1d75c" class="outline-3">
|
||||
<h3 id="orgfb1d75c">Uncle Bob’s Formatting Rules (Example in CodeAnalyzer.java)</h3>
|
||||
<div class="outline-text-3" id="text-orgfb1d75c">
|
||||
<div id="outline-container-orgc460a51" class="outline-3">
|
||||
<h3 id="orgc460a51">Uncle Bob’s Formatting Rules (Example in CodeAnalyzer.java)</h3>
|
||||
<div class="outline-text-3" id="text-orgc460a51">
|
||||
<p>
|
||||
Short, clear methods with consistent spacing and indentation.
|
||||
</p>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
||||
<head>
|
||||
<!-- 2025-08-28 Thu 17:45 -->
|
||||
<!-- 2025-09-26 Fri 15:56 -->
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Posts Introduction</title>
|
||||
@@ -220,9 +220,9 @@
|
||||
<h1 class="title">Posts Introduction</h1>
|
||||
<div class="filetags"><a href="/categories.html"> <span class="post-tag">introduction</span> </a></div>
|
||||
|
||||
<div id="outline-container-org156fb63" class="outline-2">
|
||||
<h2 id="org156fb63">Introduction</h2>
|
||||
<div class="outline-text-2" id="text-org156fb63">
|
||||
<div id="outline-container-org7b05168" class="outline-2">
|
||||
<h2 id="org7b05168">Introduction</h2>
|
||||
<div class="outline-text-2" id="text-org7b05168">
|
||||
<p>
|
||||
In this section you will find posts related to both technical and non-technical topics. As Einstein said: “If you can’t explain it simply you don’t understand it well enough”, thus the goal with these <code>posts</code> is to develop the skill of being able to deliver habitual high quality explanations as well as reinforcing the topic(s) learnt.
|
||||
</p>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
||||
<head>
|
||||
<!-- 2025-08-28 Thu 17:45 -->
|
||||
<!-- 2025-09-26 Fri 15:56 -->
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Posts List</title>
|
||||
@@ -214,16 +214,16 @@
|
||||
</nav>
|
||||
<button class="theme-toggle" id="theme-toggle" type="button" aria-label="Toggle dark mode">🌗 Theme</button>
|
||||
</div>
|
||||
<div id="updated">Updated: 2025-08-28 Thu 17:45</div>
|
||||
<div id="updated">Updated: 2025-09-26 Fri 15:56</div>
|
||||
</div>
|
||||
<div id="content" class="content">
|
||||
<h1 class="title">Posts List</h1>
|
||||
<p>
|
||||
See the categories: <a href="../categories.html">Categories</a>
|
||||
</p>
|
||||
<div id="outline-container-orga79f6ce" class="outline-2">
|
||||
<h2 id="orga79f6ce">Posts:</h2>
|
||||
<div class="outline-text-2" id="text-orga79f6ce">
|
||||
<div id="outline-container-orgec61047" class="outline-2">
|
||||
<h2 id="orgec61047">Posts:</h2>
|
||||
<div class="outline-text-2" id="text-orgec61047">
|
||||
<ul class="org-ul">
|
||||
<li><a href="clean-code/clean-code-chapter-5.html">Clean Code: Chapter 5 Notes</a> <span class="post-date">28-08-2025 17:03</span> <a href="/tags/books.html"> <span class="post-tag">books</span> </a> <a href="/tags/notes.html"> <span class="post-tag">notes</span> </a></li>
|
||||
<li><a href="clean-code/clean-code-chapter-4.html">Clean Code: Chapter 4 Notes</a> <span class="post-date">28-08-2025 16:38</span> <a href="/tags/books.html"> <span class="post-tag">books</span> </a> <a href="/tags/notes.html"> <span class="post-tag">notes</span> </a></li>
|
||||
|
||||
Reference in New Issue
Block a user