Five Lines of Code: How and When to Refactor (Paperback)
暫譯: 五行程式碼:何時及如何重構

Clausen, Christian

買這商品的人也買了...

商品描述

Five Lines of Code teaches refactoring that's focused on concrete rules and getting any method down to five lines or less! There's no jargon or tricky automated-testing skills required, just easy guidelines and patterns illustrated by detailed code samples.

In Five Lines of Code you will learn:

The signs of bad code
Improving code safely, even when you don't understand it
Balancing optimization and code generality
Proper compiler practices
The Extract method, Introducing Strategy pattern, and many other refactoring patterns
Writing stable code that enables change-by-addition
Writing code that needs no comments
Real-world practices for great refactoring

Improving existing code--refactoring--is one of the most common tasks you'll face as a programmer. Five Lines of Code teaches you clear and actionable refactoring rules that you can apply without relying on intuitive judgements such as "code smells." Following the author's expert perspective--that refactoring and code smells can be learned by following a concrete set of principles--you'll learn when to refactor your code, what patterns to apply to what problem, and the code characteristics that indicate it's time for a rework.

Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.

About the technology
Every codebase includes mistakes and inefficiencies that you need to find and fix. Refactor the right way, and your code becomes elegant, easy to read, and easy to maintain. In this book, you'll learn a unique approach to refactoring that implements any method in five lines or fewer. You'll also discover a secret most senior devs know: sometimes it's quicker to hammer out code and fix it later!

About the book
Five Lines of Code is a fresh look at refactoring for developers of all skill levels. In it, you'll master author Christian Clausen's innovative approach, learning concrete rules to get any method down to five lines--or less! You'll learn when to refactor, specific refactoring patterns that apply to most common problems, and characteristics of code that should be deleted altogether.

What's inside

The signs of bad code
Improving code safely, even when you don't understand it
Balancing optimization and code generality
Proper compiler practices

About the reader
For developers of all skill levels. Examples use easy-to-read Typescript, in the same style as Java and C#.

About the author
Christian Clausen works as a Technical Agile Coach, teaching teams how to refactor code.

Table of Contents
1 Refactoring refactoring
2 Looking under the hood of refactoring
PART 1 LEARN BY REFACTORING A COMPUTER GAME
3 Shatter long function
4 Make type codes work
5 Fuse similar code together
6 Defend the data
PART 2 TAKING WHAT YOU HAVE LEARNED INTO THE REAL WORLD
7 Collaborate with the compiler
8 Stay away from comments
9 Love deleting code
10 Never be afraid to add code
11 Follow the structure in the code
12 Avoid optimizations and generality
13 Make bad code look bad
14 Wrapping up

商品描述(中文翻譯)

《五行程式碼》教導以具體規則為重點的重構,並將任何方法縮減至五行或更少!不需要行話或複雜的自動化測試技能,只需簡單的指導方針和詳細的程式碼範例來說明。

在《五行程式碼》中,您將學到:

壞程式碼的徵兆
安全地改善程式碼,即使您不理解它
平衡優化與程式碼通用性
正確的編譯器實踐
提取方法、引入策略模式及其他多種重構模式
撰寫穩定的程式碼以支持增量變更
撰寫不需要註解的程式碼
實際的優秀重構實踐

改善現有程式碼——重構——是您作為程式設計師面對的最常見任務之一。《五行程式碼》教您清晰且可行的重構規則,您可以在不依賴直覺判斷(如「程式碼異味」)的情況下應用這些規則。遵循作者的專業觀點——重構和程式碼異味可以通過遵循一套具體的原則來學習——您將學會何時重構程式碼、針對什麼問題應用哪些模式,以及指示需要重做的程式碼特徵。

購買印刷版書籍可獲得Manning Publications提供的免費PDF、Kindle和ePub格式電子書。

關於技術
每個程式碼庫都包含需要您找到並修正的錯誤和低效之處。以正確的方式重構,您的程式碼將變得優雅、易讀且易於維護。在本書中,您將學習一種獨特的重構方法,將任何方法實現為五行或更少。您還將發現大多數資深開發者知道的一個秘密:有時候,快速編寫程式碼並在之後修正會更快!

關於本書
《五行程式碼》為各種技能水平的開發者提供了重構的新視角。在這本書中,您將掌握作者Christian Clausen的創新方法,學習具體的規則將任何方法縮減至五行或更少!您將學會何時重構、適用於最常見問題的具體重構模式,以及應該完全刪除的程式碼特徵。

內容概覽

壞程式碼的徵兆
安全地改善程式碼,即使您不理解它
平衡優化與程式碼通用性
正確的編譯器實踐

關於讀者
適合各種技能水平的開發者。範例使用易讀的TypeScript,風格與Java和C#相同。

關於作者
**Christian Clausen** 擔任技術敏捷教練,教導團隊如何重構程式碼。

目錄
1 重構重構
2 深入了解重構的內部運作
第一部分 通過重構電腦遊戲來學習
3 碎片化長函數
4 使類型代碼運作
5 將相似的程式碼融合在一起
6 保護數據
第二部分 將您所學的應用於現實世界
7 與編譯器協作
8 遠離註解
9 喜愛刪除程式碼
10 永遠不要害怕添加程式碼
11 遵循程式碼中的結構
12 避免優化和通用性
13 讓壞程式碼看起來糟糕
14 總結

作者簡介

Christian Clausen works as a Technical Agile Coach teaching teams how to properly refactor their code. Previously he worked as a software engineer on the Coccinelle semantic patching project, an automated refactoring tool. He has an MSc in computer science, and five years' experience teaching software quality at a university level.

作者簡介(中文翻譯)

Christian Clausen 擔任技術敏捷教練,教授團隊如何正確地重構他們的程式碼。之前,他曾在 Coccinelle 語意補丁專案擔任軟體工程師,這是一個自動化重構工具。他擁有計算機科學碩士學位,並在大學層級教授軟體品質已有五年的經驗。