🏷️NamingBasic意圖揭露命名 (Intention-Revealing Names)避免誤導 (Avoid Disinformation)可朗誦與可搜尋的名字 (Pronounceable & Searchable Names)名稱長度與作用域 (Length & Scope)別把型別編進名字 (Avoid Encodings)Advanced一詞一概念與一致性 (Consistency)詞性與上下文 (Parts of Speech & Context)問題領域 vs 解決方案領域命名 (Problem vs Solution Domain Names)
🧱FunctionsBasic小函式,只做一件事 (Do One Thing)函式參數 (Function Arguments)分離命令與查詢 (Command-Query Separation)Advanced錯誤處理:例外優於錯誤碼 (Error Handling)避免副作用 (Avoid Side Effects)
📝Comments & FormattingBasic好註解解釋「為什麼」 (Comments)註解要寫程式碼看不出的事 (Comments Describe the Non-Obvious)編排即溝通 (Formatting)Advanced先寫註解 (Write the Comments First)
👃Code SmellsBasic重複的程式碼 (Duplicated Code)長函式 (Long Function)過長的參數列 (Long Parameter List)神秘的命名 (Mysterious Name)過大的類別 (Large Class)Advanced依戀情結 (Feature Envy)資料泥團 (Data Clumps)基本型態偏執 (Primitive Obsession)發散式修改與散彈式修改 (Divergent Change & Shotgun Surgery)可變資料 (Mutable Data)訊息鏈與中間人 (Message Chains & Middle Man)
🔧Refactoring MovesBasic提取函式 (Extract Function)內聯函式 (Inline Function)提取變數 (Extract Variable)更改函式宣告 (Change Function Declaration)以防衛敘句取代巢狀條件 (Replace Nested Conditional with Guard Clauses)Advanced提取類別 (Extract Class)移動函式 (Move Function)引入參數物件 (Introduce Parameter Object)以查詢取代暫存變數 (Replace Temp with Query)拆分階段 (Split Phase)以多型取代條件式 (Replace Conditional with Polymorphism)分解條件式 (Decompose Conditional)封裝變數 (Encapsulate Variable)
🧪TestingBasic什麼是單元測試 (What Is a Unit Test)整潔測試:FIRST 與 AAA (Clean Tests)TDD 節奏:紅-綠-重構 (Red-Green-Refactor)測試替身:Stub vs. Mock (Test Doubles)Advanced好測試的三支柱:可信賴與可維護 (Pillars of Good Unit Tests)測試的組織與命名 (Test Organization & Naming)為可測試性而設計 (Design for Testability)
🏚️Legacy CodeBasic遺留碼與改動兩難 (Legacy Code & the Change Dilemma)看懂遺留碼 (Understanding Legacy Code)接縫模型 (The Seam Model)特徵測試 (Characterization Tests)Advanced打破依賴的手法 (Dependency-Breaking Techniques)Sprout 與 Wrap:不動舊碼加行為 (Sprout & Wrap)以差異編程 (Programming by Difference)
🧠ComplexityBasic複雜度的本質 (The Nature of Complexity)策略式 vs. 戰術式編程 (Strategic vs. Tactical Programming)深模組 (Deep Modules)程式碼要一目瞭然 (Code Should Be Obvious)Advanced通用模組更深 (General-Purpose Modules Are Deeper)不同層,不同抽象 (Different Layer, Different Abstraction)把複雜度往下拉 (Pull Complexity Downwards)合在一起,還是分開? (Better Together or Better Apart?)讓錯誤不存在 (Define Errors Out of Existence)設計兩次 (Design It Twice)
🔍Code ReviewBasic為何做程式碼審查 (Why Code Review)程式碼審查實務準則 (Code Review Best Practices)Advanced實戰流程:Critique 審查工具 (Code Review in Practice)大規模變更與所有權 (Large-Scale Changes & Ownership)