Now Reading
Rule of three (laptop programming)

Rule of three (laptop programming)

2023-08-30 05:28:24

From Wikipedia, the free encyclopedia

Rule of three (“Three strikes and also you refactor”) is a code refactoring rule of thumb to resolve when related items of code ought to be refactored to keep away from duplication. It states that two situations of comparable code don’t require refactoring, however when related code is used thrice, it ought to be extracted into a brand new process. The rule was popularised by Martin Fowler in Refactoring[1] and attributed to Don Roberts.

Duplication is taken into account a foul apply in programming as a result of it makes the code more durable to maintain. When the rule encoded in a replicated piece of code adjustments, whoever maintains the code should change it in every single place accurately.

Nonetheless, selecting an acceptable design to keep away from duplication may profit from extra examples to see patterns in. Making an attempt untimely refactoring dangers deciding on a fallacious abstraction, which may end up in worse code as new necessities emerge[2] and can ultimately have to be refactored once more.

See Also

The rule implies that the price of upkeep outweighs the price of refactoring and potential dangerous design when there are three copies, and will or might not if there are solely two copies.

See additionally[edit]

References[edit]


Source Link

What's Your Reaction?
Excited
0
Happy
0
In Love
0
Not Sure
0
Silly
0
View Comments (0)

Leave a Reply

Your email address will not be published.

2022 Blinking Robots.
WordPress by Doejo

Scroll To Top