When You SHOULD Duplicate Code

Highlights

  • The Single Responsibility Principle states that a given method/class/component should have a single reason to change

  • repeats the same knowledge and business logic

  • If you are not sure you can ask a replacement question: Does changing one code block lead to changing the other one?

  • Does code exist that looks identical?Does the code repeat the same knowledge and logic

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