<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://suhrid.net/wiki/index.php?action=history&amp;feed=atom&amp;title=Strategy_Pattern</id>
	<title>Strategy Pattern - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://suhrid.net/wiki/index.php?action=history&amp;feed=atom&amp;title=Strategy_Pattern"/>
	<link rel="alternate" type="text/html" href="https://suhrid.net/wiki/index.php?title=Strategy_Pattern&amp;action=history"/>
	<updated>2026-04-15T23:08:16Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.2</generator>
	<entry>
		<id>https://suhrid.net/wiki/index.php?title=Strategy_Pattern&amp;diff=1710&amp;oldid=prev</id>
		<title>Suhridk at 21:07, 13 June 2012</title>
		<link rel="alternate" type="text/html" href="https://suhrid.net/wiki/index.php?title=Strategy_Pattern&amp;diff=1710&amp;oldid=prev"/>
		<updated>2012-06-13T21:07:01Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 21:07, 13 June 2012&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l44&quot; &gt;Line 44:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 44:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Another example from Wikipedia:&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Another example from Wikipedia:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;http://&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;en&lt;/del&gt;.&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;wikipedia&lt;/del&gt;.org/&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;wiki&lt;/del&gt;/&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;File:&lt;/del&gt;StrategyPattern_IBrakeBehavior.svg&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;http://&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;upload&lt;/ins&gt;.&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;wikimedia&lt;/ins&gt;.org/&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;wikipedia/commons/4/4b&lt;/ins&gt;/StrategyPattern_IBrakeBehavior.svg&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Suhridk</name></author>
		
	</entry>
	<entry>
		<id>https://suhrid.net/wiki/index.php?title=Strategy_Pattern&amp;diff=1709&amp;oldid=prev</id>
		<title>Suhridk at 21:06, 13 June 2012</title>
		<link rel="alternate" type="text/html" href="https://suhrid.net/wiki/index.php?title=Strategy_Pattern&amp;diff=1709&amp;oldid=prev"/>
		<updated>2012-06-13T21:06:09Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 21:06, 13 June 2012&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l41&quot; &gt;Line 41:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 41:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* Another example from Wikipedia:&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;http://en.wikipedia.org/wiki/File:StrategyPattern_IBrakeBehavior.svg&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Suhridk</name></author>
		
	</entry>
	<entry>
		<id>https://suhrid.net/wiki/index.php?title=Strategy_Pattern&amp;diff=1708&amp;oldid=prev</id>
		<title>Suhridk: Created page with &quot;* Strategy lets the algorithm vary independently from the clients that use it.  * For e.g. let&#039;s say we have a base class that has defined a method called sort. * Now many subcla...&quot;</title>
		<link rel="alternate" type="text/html" href="https://suhrid.net/wiki/index.php?title=Strategy_Pattern&amp;diff=1708&amp;oldid=prev"/>
		<updated>2012-06-13T20:56:13Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;* Strategy lets the algorithm vary independently from the clients that use it.  * For e.g. let&amp;#039;s say we have a base class that has defined a method called sort. * Now many subcla...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;* Strategy lets the algorithm vary independently from the clients that use it. &lt;br /&gt;
* For e.g. let&amp;#039;s say we have a base class that has defined a method called sort.&lt;br /&gt;
* Now many subclasses inherit from it. Probably not all the subclasses are sortable,  so it may not make sense to add sort() in the base class. &lt;br /&gt;
* Alternatively an interface called sortable can be defined, and only sortable subclasses can implement the interface.&lt;br /&gt;
* The disadvantage with this is every time sort algorithm needs to change, all the base classes that are sortable need to change - maintenance headache.&lt;br /&gt;
* A solution is to encapsulate the sort algorithm into a separate interface and concrete classes.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java5&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
interface SortAlgo {&lt;br /&gt;
   public void sort();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class QuickSort implements SortAlgo {&lt;br /&gt;
   public void sort() {&lt;br /&gt;
      //....&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class BubbleSort implements SortAlgo {&lt;br /&gt;
   public void sort() {&lt;br /&gt;
      //....&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Base {&lt;br /&gt;
  SortAlgo sortAlgo;&lt;br /&gt;
&lt;br /&gt;
  public void doSort() {&lt;br /&gt;
      sortAlgo.sort();&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Sub extends Base {&lt;br /&gt;
   public Sub() {&lt;br /&gt;
       sortAlgo = new QuickSort();&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Suhridk</name></author>
		
	</entry>
</feed>