Class 08
Index
Don’t repeat yourself but consider the Rule of Three
Don't repeat yourself (DRY) is a principle of software development aimed at reducing repetition of software patterns, replacing it with abstractions or using data normalization to avoid redundancy.
DRY: “Every piece of knowledge must have a single, unambiguous, authoritative representation within a system”
Rule of three (“Three strikes and you refactor”) is a code refactoring rule of thumb to decide when similar pieces of code should be refactored to avoid duplication. It states that two instances of similar code do not require refactoring, but when similar code is used three times, it should be extracted into a new procedure. The rule was popularised by Martin Fowler in Refactoring[1] and attributed to Don Roberts.
Duplication is considered a bad practice in programming because it makes the code harder to maintain. When the rule encoded in a replicated piece of code changes, whoever maintains the code will have to change it in all places correctly.
You Aren’t Gonna Need It and Minimum Viable Product
You aren't gonna need it (YAGNI) is a principle which arose from extreme programming (XP) that states a programmer should not add functionality until deemed necessary.
“Always implement things when you actually need them, never when you just foresee that you need them.” - Ron Jeffries
“It is hard for less experienced developers to appreciate how rarely architecting for future requirements / applications turns out net-positive. - John Carmack
A minimum viable product (MVP) is a version of a product with just enough features to be usable by early customers who can then provide feedback for future product development.
Developers potentially avoid lengthy and (possibly) unnecessary work. Instead, they iterate on working versions and respond to feedback, challenging and validating assumptions about a product’s requirements.
It may also involve carrying out market analysis beforehand.