<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=Rule_of_three_%28computer_programming%29</id>
	<title>Rule of three (computer programming) - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=Rule_of_three_%28computer_programming%29"/>
	<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Rule_of_three_(computer_programming)&amp;action=history"/>
	<updated>2026-10-26T20:01:56Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>http://debianws.lexgopc.com/wiki143/index.php?title=Rule_of_three_(computer_programming)&amp;diff=6095131&amp;oldid=prev</id>
		<title>imported&gt;MichaelMaggs: Adding local short description: &quot;Refactoring rule of thumb&quot;, overriding Wikidata description &quot;computer programming refactoring rule of thumb&quot;</title>
		<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Rule_of_three_(computer_programming)&amp;diff=6095131&amp;oldid=prev"/>
		<updated>2023-09-03T21:33:29Z</updated>

		<summary type="html">&lt;p&gt;Adding local &lt;a href=&quot;https://en.wikipedia.org/wiki/Short_description&quot; class=&quot;extiw&quot; title=&quot;wikipedia:Short description&quot;&gt;short description&lt;/a&gt;: &amp;quot;Refactoring rule of thumb&amp;quot;, overriding Wikidata description &amp;quot;computer programming refactoring rule of thumb&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Short description|Refactoring rule of thumb}}&lt;br /&gt;
{{For|the C++ principle|Rule of three (C++ programming)}}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Rule of three&amp;#039;&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;quot;Three strikes and you refactor&amp;quot;&amp;#039;&amp;#039;) 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 (software engineer)|Martin Fowler]] in &amp;#039;&amp;#039;Refactoring&amp;#039;&amp;#039;&amp;lt;ref&amp;gt;{{cite book|title=Refactoring: Improving the Design of Existing Code|author=Martin Fowler|author2=Kent Beck|author3=John Brant|author4=William Opdyke|author5=Don Roberts|isbn=978-0201485677|year=1999|publisher=Addison-Wesley Professional|url-access=registration|url=https://archive.org/details/isbn_9780201485677}}&amp;lt;/ref&amp;gt; and attributed to Don Roberts.&lt;br /&gt;
&lt;br /&gt;
[[Code duplication|Duplication]] is considered a bad practice in programming because it makes the code harder to [[Software maintenance|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.&lt;br /&gt;
&lt;br /&gt;
However, choosing an appropriate design to avoid duplication might benefit from more examples to see patterns in. Attempting premature refactoring risks selecting a wrong abstraction, which can result in worse code as new requirements emerge&amp;lt;ref&amp;gt;[[Sandi Metz]], [https://www.sandimetz.com/blog/2016/1/20/the-wrong-abstraction &amp;#039;&amp;#039;&amp;quot;The Wrong Abstraction&amp;quot;&amp;#039;&amp;#039; (2016)]&amp;lt;/ref&amp;gt; and will eventually need to be refactored again.&lt;br /&gt;
&lt;br /&gt;
The rule implies that the cost of maintenance outweighs the cost of refactoring and potential bad design when there are three copies, and may or may not if there are only two copies.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Copy-and-paste programming]]&lt;br /&gt;
* [[Don&amp;#039;t repeat yourself]] (DRY)&lt;br /&gt;
* [[You aren&amp;#039;t gonna need it]]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Computer programming folklore]]&lt;br /&gt;
[[Category:Programming principles]]&lt;/div&gt;</summary>
		<author><name>imported&gt;MichaelMaggs</name></author>
	</entry>
</feed>