Code-Memo

DRY Principle

Concepts:

  1. Single Source of Truth (SSOT): Ensure that every piece of knowledge or logic is represented in one place within the codebase. This helps in maintaining consistency and makes updates easier.

  2. Abstraction: Use functions, classes, and modules to abstract common logic. This avoids repeating the same code and makes the system more modular and easier to maintain.

  3. Reusability: Write code in a way that it can be reused across the system. This reduces redundancy and promotes cleaner and more efficient code.

Benefits:

  1. Maintainability:Changes are easier to implement and errors are less likely to occur since updates need to be made in only one place.

  2. Readability: Code is easier to read and understand when there’s no unnecessary repetition.

  3. Reduced Errors: By avoiding duplicate code, the risk of inconsistencies and errors is minimized.

NOTE: Avoid abstracting too early or too much, which can lead to complex and hard-to-understand code.