nhungpham1512 / automation_testing_beginner

automation testing course aLinh
0 stars 0 forks source link

DRY Principle #3

Closed jacobvn84 closed 1 year ago

jacobvn84 commented 1 year ago

"Don't repeat yourself" (DRY) is a principle of software development aimed at reducing repetition of information which is likely to change, replacing it with abstractions that are less likely to change, or using data normalization which avoids redundancy in the first place.

The DRY principle is stated as "Every piece of knowledge must have a single, unambiguous, authoritative representation within a system". The principle has been formulated by Andy Hunt and Dave Thomas in their book The Pragmatic Programmer.[1] They apply it quite broadly to include database schemas, test plans, the build system, even documentation.[2] When the DRY principle is applied successfully, a modification of any single element of a system does not require a change in other logically unrelated elements. Additionally, elements that are logically related all change predictably and uniformly, and are thus kept in sync. Besides using methods and subroutines in their code, Thomas and Hunt rely on code generators, automatic build systems, and scripting languages to observe the DRY principle across layers.

jacobvn84 commented 1 year ago

Lặp lại những thứ có thể nhìn thấy Lặp lại những thứ không nhìn thấy

Ví dụ và bài học.

nhungpham1512 commented 1 year ago

Sử dụng refactor đến dọn dẹp gọn gàng lại code. Mục đích khi muốn thay đổi nó, chỉ cần thay đổi 1 chỗ duy nhất và sự thay đổi sẽ tự động được apply cho tất cả các chỗ trong code, thay vì đi tìm từng chỗ và copy paste lại chúng

  1. Rename
  2. Introduce Contanst, Introduce Field, Introduce Parameter,...
  3. Move member