Rule of three (computer programming)

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.

Source: Wikipedia — Rule of three (computer programming) (CC BY-SA 4.0)

Rule of three (computer programming)

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.

Source: Wikipedia "Rule of three (computer programming)" · CC BY-SA 4.0

Share this article: X · Bluesky
Privacy Policy