WET = Write Everything Twice
初學者應學習避免的一種程式寫法
In the software engineering world, there is a concept of WET code and DRY code.
DRY stands for “Don’t Repeat Yourself”, while WET stands for “We Enjoy Typing” or “Write Everything Twice” (or Thrice!)
Good code is generally pretty DRY. Never repeating itself.
Sloppy code is often pretty WET. The same lines (or variations of the same lines) are often repeated over and over in different places.
Why is repeating code bad? Imagine having the same block of code repeated in 3 different sections of your program. Then imagine changing the logic to that block of code because you wanted to fix a bug or improve performance. Well, now you have to find all the instances of that code block and update it in all 3 locations.
When you first write out new code, you’ll often have WET code. And that’s both common and fairly normal. What is bad is if you decide not to refactor and leave it WET.
等到寫程式一段日子了
就可以自己判斷/選擇要寫WET/DRY code了