DEV Community

Discussion on: What's your favorite software idiom/aphorism?

Collapse
 
maestromac profile image
Mac Siri

My favorite is rule of three. It's the one rule I always refer to when I review PRs.

Rule of three 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 don't 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 and attributed to Don Roberts.