The first principle of the red grade is Don't Repeat Yourself or DRY. It's origin can be found in the Pragmatic Programmer, one of the most important books in the programming world.


DRY tackles code repetition and states that we should avoid it.

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

Quite simple and obvious thing. However, not everybody follows this. The copy and paste is much easier than having to think how to avoid this duplication.

Much easier? well, at the moment.. But what about when you came back to that piece of code and whant to change something? You will have to make sure that you are making the change in every duplicated piece.. if the duplication has happened in more than a place this could became a maintenance nightmare. Also, this duplication it is just clutter in the code which makes in more difficult to read. And we spend most of time reading code.

So, if you want to write maintainable clean code DO NOT REPEAT YOURSELF!