不要重複你自己

Don’t Repeat Yourself (DRY)

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

系統中的每個部分,都必須要有唯一、明確且權威的代表。


在許多部分,有著重覆的程式碼,會造成將來修改時有所遺漏,
透過遵守 DRY ,修改一處程式碼後,其餘地方便會同步改變。

不要用複製貼上編程法
(Copy-and-paste programming)

而違反 DRY 原則,又被戲稱為 WET
“Write Every Time”
“We Enjoy Typing”


ʕ •ᴥ•ʔ:Avoid writing duplicate code !