<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>Agile Software Development Book Review</title><link>http://davidhayden.com/blog/dave/category/42.aspx</link><description>Agile Software Development Book Review</description><managingEditor>Dave Hayden</managingEditor><dc:language>en-US</dc:language><generator>.Text Version 0.95.2004.101</generator><item><dc:creator>Dave Hayden</dc:creator><title>Desirable Characteristics of Application Design - Design Smells of Rotting Software - GRASP Patterns - Object-Oriented Principles</title><link>http://davidhayden.com/blog/dave/archive/2005/08/09/2421.aspx</link><pubDate>Tue, 09 Aug 2005 19:02:00 GMT</pubDate><guid>http://davidhayden.com/blog/dave/archive/2005/08/09/2421.aspx</guid><description>&lt;P&gt;&lt;FONT face=Verdana size=2&gt;I think that most developers these days often have to play the role of architect.&amp;nbsp; They are not only responsible for coding, but also responsible for the overall design of the application.&amp;nbsp; Hence, we find ourselves putting on several hats during various phases and iterations of a project.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;This is okay by me given that more and more companies are embracing agile software development.&amp;nbsp; I find that I am focusing more on those tasks that lead to better applications in less time as opposed to paperwork and communication that only appease management and have little real-world value.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;As &amp;#8220;architects&amp;#8221;, we need to understand characteristics of good application design.&amp;nbsp; We need to follow proven principles and best practices that are language and development enviroment agnostic.&amp;nbsp; If nothing else, we need to sound like we know what the hell we are talking about ;)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;In several posts I have mentioned the &lt;/FONT&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/05/19/1029.aspx"&gt;&lt;FONT face=Verdana size=2&gt;application design smells of rotting software&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt;, which are unfavorable characteristics of an application (i.e. things you don't want):&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;Rigidity&lt;/STRONG&gt; - System is hard to change. &lt;/FONT&gt;&lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;Fragility&lt;/STRONG&gt; - Changes causes system to break easily and require other changes. &lt;/FONT&gt;&lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;Immobility&lt;/STRONG&gt; - Difficult to entangle components that can be reused in other systems. &lt;/FONT&gt;&lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;Viscosity&lt;/STRONG&gt; - Doing things right is harder than doing things wrong. &lt;/FONT&gt;&lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;Needless Complexity&lt;/STRONG&gt; - System contains infrastructure that has no direct benefit. &lt;/FONT&gt;&lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;Needless Repetition&lt;/STRONG&gt; - Repeated structures that should have a single abstraction. &lt;/FONT&gt;&lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;Opacity&lt;/STRONG&gt; - Code is hard to understand.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;I have also mentioned my ever favorite &lt;/FONT&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2004/11/19/631.aspx"&gt;&lt;FONT face=Verdana size=2&gt;GRASP Patterns&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt;&amp;nbsp;from &lt;/FONT&gt;&lt;A href="http://davidhayden.com/blog/dave/category/33.aspx"&gt;&lt;FONT face=Verdana size=2&gt;Applying UML and Design Patterns - An Introduction to Object-Oriented Analysis and Design and Iterative Development by Craig Larman&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt;, which are useful as a learning aid for OO design with responsibilities:&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/03/27/895.aspx"&gt;Information Expert&lt;/A&gt;&lt;/STRONG&gt; - A general principal of object design and responsibility assignment? &lt;/FONT&gt;&lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2004/12/06/667.aspx"&gt;Creator&lt;/A&gt;&lt;/STRONG&gt; - Who creates? &lt;/FONT&gt;&lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2004/11/28/648.aspx"&gt;Controller&lt;/A&gt;&lt;/STRONG&gt; - What first object beyond the UI layer receives and coordinates a system operation? &lt;/FONT&gt;&lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2004/12/14/690.aspx"&gt;Low Coupling&lt;/A&gt;&lt;/STRONG&gt; - How to reduce the impact of change? &lt;/FONT&gt;&lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2004/12/10/680.aspx"&gt;High Cohesion&lt;/A&gt;&lt;/STRONG&gt; - How to keep objects focused, understandable, and manageable? &lt;/FONT&gt;&lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;Polymorphism&lt;/STRONG&gt; - Who is responsible when behavior varies by type? &lt;/FONT&gt;&lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;Pure Fabrication&lt;/STRONG&gt; - Who is responsible when you are desperate, and do not want to violate high cohesion and low coupling? &lt;/FONT&gt;&lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;Indirection&lt;/STRONG&gt; - How to assign responsibilities to avoid direct coupling? &lt;/FONT&gt;&lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;Protected Variations&lt;/STRONG&gt; - How to assign responsibilities so that the variations or instability in the elements do not have an undesirable impact on other elements?&lt;/FONT&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;I also&amp;nbsp;described a chapter of Code Complete 2 that mentioned several &lt;/FONT&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2004/12/17/700.aspx"&gt;&lt;FONT face=Verdana size=2&gt;desirable characteristics of a design&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt;:&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;Minimal complexity&lt;/STRONG&gt; - Avoid making &amp;#8220;clever&amp;#8220; designs.&amp;nbsp; Clever designs are usually hard to understand.&amp;nbsp; Keep it simple. &lt;/FONT&gt;&lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;Ease of maintenance&lt;/STRONG&gt; &lt;/FONT&gt;&lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;Loose coupling&lt;/STRONG&gt; - Loose coupling means designing so that you hold connections among different parts of a program to a minimum. &lt;/FONT&gt;&lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;Extensability&lt;/STRONG&gt; - You should be able to change a piece of the system without causing a huge impact to other pieces of the system. &lt;/FONT&gt;&lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;Reusability&lt;/STRONG&gt; &lt;/FONT&gt;&lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;High fan-in&lt;/STRONG&gt; - Refers to having a high number of classes that use a given class.&amp;nbsp; High fan-in implies that a system has been designed to make good use of utilitity classes at the lower levels in the system. &lt;/FONT&gt;&lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;Low-to-medium fan-out&lt;/STRONG&gt; - A given class should use a low-to-medium number of other classes.&amp;nbsp; High fan-out (more than about seven) indicates a class uses a large number of other classes and may be overly complex. &lt;/FONT&gt;&lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;Portability&lt;/STRONG&gt; &lt;/FONT&gt;&lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;Leanness&lt;/STRONG&gt; &lt;/FONT&gt;&lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;Stratification&lt;/STRONG&gt; - Try to keep the levels of decomposition stratified so you can view the system at any single level without dipping into other levels. &lt;/FONT&gt;&lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;Standard techniques&lt;/STRONG&gt; - Give the whole system a familiar feeling by using standardized, common approaches.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;And last, I talked about several Object-Oriented Principles from my &lt;/FONT&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/06/17/1573.aspx"&gt;&lt;FONT face=Verdana size=2&gt;Agile Software Development Principles, Patterns, and Practices Book Review&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt;:&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/05/29/1066.aspx"&gt;&lt;FONT face=Verdana size=2&gt;Single-Responsibility Principle&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt;&amp;nbsp;: A class should have only one reason to change.&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/06/04/1096.aspx"&gt;&lt;FONT face=Verdana size=2&gt;Open-Closed Principle&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt;&amp;nbsp;: Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification.&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/06/10/1226.aspx"&gt;&lt;FONT face=Verdana size=2&gt;The Liskov Substitution Principle&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt;&amp;nbsp;: What is wanted is something like the following substitution property: If for each object o1 of type S there is an object o2 of type T such that for all programs P defined in terms of T, the behavior of P is unchanged when o1 is substituted for o2, then S is a subtype of T.&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/06/10/1261.aspx"&gt;&lt;FONT face=Verdana size=2&gt;Dependency-Inversion Principle&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt;&amp;nbsp;: A. High-level modules should not depend on low-level modules. Both should depend on abstractions. B. Abstractions should not depend on details. Details should depend on abstractions.&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/06/15/1482.aspx"&gt;&lt;FONT face=Verdana size=2&gt;Interface-Segregation Principle&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt;&amp;nbsp;: Clients should not be forced to depend on methods that they do not use.&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;As I look back at all of this conceptual information, I see a consitency.&amp;nbsp; Actually, I see a redundancy where all of these books are talking about the same principles of good application design in their own way.&amp;nbsp; I find this great and&amp;nbsp;really enjoy the reinforcement, because it helps me when I need to put on that &amp;#8220;architect&amp;#8221; hat.&amp;nbsp; I can speak and think with confidence with respect to all the authors who have much more experience on these subjects than myself.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Keep this list handy as I hope it will be useful when you need to think about the design and architecture of your next application.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face=Verdana size=2&gt;Resources&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://davidhayden.com/blog/dave/category/42.aspx"&gt;&lt;FONT face=Verdana size=2&gt;Agile Software Development Principles, Patterns, and Practices Book Review&lt;/FONT&gt;&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://davidhayden.com/blog/dave/category/33.aspx"&gt;&lt;FONT face=Verdana size=2&gt;Applying UML and Design Patterns - An Introduction to Object-Oriented Analysis and Design and Iterative Development by Craig Larman&lt;/FONT&gt;&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2004/11/19/631.aspx"&gt;&lt;FONT face=Verdana size=2&gt;GRASP Patterns&lt;/FONT&gt;&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2004/12/17/700.aspx"&gt;&lt;FONT face=Verdana size=2&gt;Code Complete 2 - Desirable Characteristics of a Design&lt;/FONT&gt;&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;A href="http://www.davidhayden.com/"&gt;David Hayden&lt;/A&gt; ( &lt;A href="http://www.davidhayden.com/"&gt;Sarasota Web Design&lt;/A&gt; / &lt;A href="http://davidhayden.com/blog/dave/"&gt;Blog&lt;/A&gt; )&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Drinking: &lt;A href="http://www.relaxsipenjoy.com/dragon_well_lung_ching_china_green_tea.aspx"&gt;Dragon Well Lung Ching Green Tea&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src ="http://davidhayden.com/blog/dave/aggbug/2421.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Dave Hayden</dc:creator><title>Objections to Agile Development White Paper - Awesome!</title><link>http://davidhayden.com/blog/dave/archive/2005/07/29/2408.aspx</link><pubDate>Fri, 29 Jul 2005 17:47:00 GMT</pubDate><guid>http://davidhayden.com/blog/dave/archive/2005/07/29/2408.aspx</guid><description>&lt;P&gt;&lt;FONT face=Verdana size=2&gt;If you do nothing else this weekend :), I highly recommend one read Jim Highsmith's &lt;A href="http://www.cutter.com/research/freestuff/AgileObjections.pdf" target=_blank&gt;white paper&lt;/A&gt;, called &lt;STRONG&gt;Objections to Agile Development&lt;/STRONG&gt;.&amp;nbsp; I just finished reading the white paper, and it is awesome!&amp;nbsp; Don't even waste your time trying to mark it up with a highlighter, because the entire white paper is packed with great information.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face=Verdana size=2&gt;On Ad Hoc Development&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Jim coins a new term for me, called &lt;STRONG&gt;Ad Hoc Development&lt;/STRONG&gt;, which is essentially the practice by some developers to get out of all design, documentation, modeling, etc.&amp;nbsp;and label it&amp;nbsp;&lt;STRONG&gt;Agile Development&lt;/STRONG&gt;.&amp;nbsp; Cool term.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&amp;#8220;There is still a contingent of people who believe that agile development is an excuse to be ad hoc and undisciplined. However, technical excellence is a tenet of all agile approaches. When a code base has automated tests, is refined to maintain quality as the project proceeds, is continuously integrated, and so on, it is very difficult to label the results as poor quality.&amp;#8220; - Jim Highsmith&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face=Verdana size=2&gt;On Architectural and Design Excellence&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&amp;#8220;Agile approaches actually encourage &amp;#8212; in fact, demand &amp;#8212; architectural and design excellence. Technical excellence is a fundamental principle of agile development. Technical excellence is obtained through the application of four key practices: ruthless testing, refactoring, simple design, and continuous integration. These four practices work together to ensure that the design is always simple, robust, and adaptable; that the code is constantly of high quality because of extensive automated testing; that the designs are constantly upgraded through refactoring as new functionality is added; and that the entire system is constantly integrated and reviewed by customers and technical staffs. All software goes though these cycles; agile developers just do them constantly in short iterations. These cycle practices keep the cost of change (iteration cost) down, in turn allowing emergent design processes to work effectively.&amp;#8220; - Jim Highsmith&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face=Verdana size=2&gt;On Iterative Design&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&amp;#8220;Iterative design (or architecture) therefore isn&amp;#8217;t lack of design, it&amp;#8217;s different design &amp;#8212; and, in fact, iterative design often yields much better designs because the designs are subjected to reality testing and copious feedback. The key to this design approach is low-cost iteration, which agile software development strives for.&amp;#8221; - Jim Highsmith&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face=Verdana size=2&gt;On Documentation&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&amp;#8220;Agile methods advocate simple, effective, low-ceremony, barely sufficient, less-formal documentation &amp;#8212; but that&amp;#8217;s a far cry from no documentation. Maybe some people don&amp;#8217;t consider story cards, whiteboard sketches, or flipchart drawings to be documentation. If so, they are missing the essence of what documentation can accomplish.&amp;#8221; - Jim Highsmith&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&amp;#8220;I&amp;#8217;ve never met a manager who didn&amp;#8217;t profess the need for documentation for maintenance and enhancements, and I&amp;#8217;ve never talked to a programmer who used much more than the existing code. That doesn&amp;#8217;t mean that some high-level documentation isn&amp;#8217;t useful; it just means that most organizations have been very ineffective with the money they have spent on documentation.&amp;#8221; - Jim Highsmith&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face=Verdana size=2&gt;On Modeling&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&amp;#8220;Agile developers aren&amp;#8217;t antimodeling, but they are anticompliance modeling. Modeling that directly contributes to delivering working software will be used by agile developers.&amp;#8220; - Jim Highsmith&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face=Verdana size=2&gt;Conclusion&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Phenomenal white paper.&amp;nbsp; Download it &lt;/FONT&gt;&lt;A href="http://www.cutter.com/research/freestuff/AgileObjections.pdf" target=_blank&gt;&lt;FONT face=Verdana size=2&gt;here&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt;.&amp;nbsp; Thanks, Jim.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;A href="http://www.davidhayden.com/"&gt;David Hayden&lt;/A&gt; ( &lt;A href="http://www.davidhayden.com/"&gt;Sarasota Web Design&lt;/A&gt; / &lt;A href="http://davidhayden.com/blog/dave/"&gt;Blog&lt;/A&gt; )&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;STRONG&gt;Drinking&lt;/STRONG&gt;: &lt;A href="http://relaxsipenjoy.com/gyokuro_japan_green_tea.aspx"&gt;Gyokuro&lt;/A&gt; &lt;A href="http://relaxsipenjoy.com/special_teas.aspx"&gt;Green Tea&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;STRONG&gt;Listening To&lt;/STRONG&gt;: Desert Rose by Sting&lt;/FONT&gt;&lt;/P&gt;&lt;img src ="http://davidhayden.com/blog/dave/aggbug/2408.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Dave Hayden</dc:creator><title>Strategy Design Pattern and Open-Closed Principle</title><link>http://davidhayden.com/blog/dave/archive/2005/07/01/1875.aspx</link><pubDate>Fri, 01 Jul 2005 17:22:00 GMT</pubDate><guid>http://davidhayden.com/blog/dave/archive/2005/07/01/1875.aspx</guid><description>&lt;P&gt;&lt;STRONG&gt;&lt;FONT face=Verdana size=2&gt;Summary&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;This post describes how the Strategy Design Pattern lets a variety of different algorithms be used interchangeably as well as&amp;nbsp;how it relates to the&amp;nbsp;Open-Closed Principle.&amp;nbsp; You can read my previous article discussing the &lt;A href="http://davidhayden.com/blog/dave/archive/2005/06/27/1869.aspx"&gt;Strategy Design Pattern and Dependency-Inversion Principle&lt;/A&gt;.&amp;nbsp; Some information is repeated here on purpose from the previous article, because it shows how&amp;nbsp;the Strategy Design Pattern&amp;nbsp;helps your applications implement&amp;nbsp;several object-oriented principles.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face=Verdana size=2&gt;Open-Closed&amp;nbsp;Principle&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;In a recent post I talked about the &lt;A href="http://davidhayden.com/blog/dave/archive/2005/06/04/1096.aspx"&gt;Open-Closed Principle&lt;/A&gt; as discussed in the the book, &lt;A href="http://davidhayden.com/blog/dave/category/42.aspx"&gt;Agile Software Development - Principles, Patterns, and Practices by Robert Martin&lt;/A&gt;.&amp;nbsp; The&amp;nbsp;Open-Closed Principle is one of five object-oriented programming principles associated with class design:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;FIELDSET&gt;&lt;LEGEND&gt;&lt;FONT face=Verdana size=2&gt;Open-Closed Principle&lt;/FONT&gt;&lt;/LEGEND&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;"Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification [Martin, p.99]"&lt;/FONT&gt;&lt;/P&gt;&lt;/FIELDSET&gt; 
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Modules that adhere to this &lt;A href="http://davidhayden.com/blog/dave/archive/2005/06/04/1096.aspx"&gt;Open-Closed Principle&lt;/A&gt; have 2 primary attributes:&lt;/FONT&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;"&lt;STRONG&gt;Open For Extension&lt;/STRONG&gt;" - It is possible to extend the behavior of the module as the requirements of the application change (i.e. change the behavior of the module). &lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;"&lt;STRONG&gt;Closed For Modification&lt;/STRONG&gt;" - Extending the behavior of the module does not result in the changing of the source code or binary code of the module itself.&lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;STRONG&gt;How This Relates to the Strategy Design Pattern&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;As discussed earlier with the &lt;A href="http://davidhayden.com/blog/dave/archive/2005/06/27/1869.aspx"&gt;Dependency-Inversion Principle&lt;/A&gt;, two design patterns that can help you&amp;nbsp;implement the&amp;nbsp;Open-Closed Principle in your applications&amp;nbsp;are the Template Method and Strategy Design Patterns.&amp;nbsp; These two&amp;nbsp;design patterns&amp;nbsp;are all about&amp;nbsp;hiding the specifics of an algorithm either via Inheritance (Template Method) or&amp;nbsp;delegation (Strategy Pattern).&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;The Strategy Design Pattern delegates algorithm specifics via an Interface.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;STRONG&gt;Example of Strategy Pattern in the .NET Framework&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;A great example of the Strategy Pattern in the .NET Framework is the sorting of objects in an ArrayList&amp;nbsp;via the &lt;A href="http://codebetter.com/blogs/david.hayden/archive/2005/03/06/56584.aspx"&gt;IComparer Interface&lt;/A&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;By default, the Sort method on ArrayList uses the QuickSort algorithm along with the &lt;A href="http://codebetter.com/blogs/david.hayden/articles/56094.aspx"&gt;IComparable implementation&amp;nbsp;of each&amp;nbsp;item&lt;/A&gt; in the list for sorting.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;However, at times it&amp;nbsp;may be necessary to sort the list in different ways. To accomplish this, there is an overload of Sort that takes an IComparer as a parameter.&amp;nbsp; If used, ArrayList&amp;nbsp;uses IComparer.Compare for the comparisons. By passing in an object that implements IComparer,&amp;nbsp;the ArrayList&amp;nbsp;can&amp;nbsp;implement other sorting&amp;nbsp;methods without caring about the details of the&amp;nbsp;comparison method.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;This is an example of the Strategy Design Pattern.&amp;nbsp; Hiding the details of the comparison method behind an Interface allows the algorithm to vary and keeps the ArrayList from being dependant on the classes that implement such algorithms.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;FIELDSET&gt;
&lt;P&gt;&lt;LEGEND&gt;&lt;FONT face=Verdana size=2&gt;Strategy Pattern with IComparer&lt;/FONT&gt;&lt;/LEGEND&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #0000ff"&gt;class&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; CoolComparer : IComparer
{
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;#region&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; IComparer Members&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;

    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; Compare(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;object&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; x, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;object&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; y)
    {
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;//&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; TODO:  implementation&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt;0&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;;
    }

    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;#endregion&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;

}


ArrayList items &lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; ArrayList();

items.Add(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;One&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
items.Add(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;Two&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
items.Add(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;Three&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);

items.Sort(); &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;//&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; Uses IComparable on string object&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;
IComparer myComparer &lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; CoolComparer();
items.Sort(myComparer); &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;//&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; Delegate Comparison Method&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/FIELDSET&gt;&lt;FONT face=Verdana size=2&gt; &lt;/FONT&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;STRONG&gt;How This Relates to the Open-Closed Principle&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;This supports the Open-Closed Principle because implementing a new comparison method for sorting objects in an ArrayList does not require a change to the ArrayList Class.&amp;nbsp; This class is essentially closed for modification.&amp;nbsp; However, because we can pass in an object that&amp;nbsp;implements &lt;STRONG&gt;IComparer&lt;/STRONG&gt;, the class is open for extension.&amp;nbsp; Extending this class only requires new code ( classes ) to be written that implement IComparer, not changes&amp;nbsp;to existing code.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face=Verdana size=2&gt;Conclusion&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;The Strategy Design Pattern is a pretty powerful and often used design pattern to loosely couple&amp;nbsp;your main classes in an&amp;nbsp;application from lower-level detail classes / algorithms.&amp;nbsp; As with all design patterns, it is best not to use them just for the sake of using them, because you will run the risk of needless complexity (&lt;A href="http://davidhayden.com/blog/dave/archive/2005/05/19/1029.aspx"&gt;application design smells&lt;/A&gt;)&amp;nbsp;in your applications.&amp;nbsp; They are best thought of as a solution to a &lt;A href="http://davidhayden.com/blog/dave/archive/2005/05/27/1054.aspx"&gt;real problem that occurs during refactoring and a method of communicating how the problem was solved&lt;/A&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;img src ="http://davidhayden.com/blog/dave/aggbug/1875.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Dave Hayden</dc:creator><title>Strategy Design Pattern and Dependency-Inversion Principle</title><link>http://davidhayden.com/blog/dave/archive/2005/06/27/1869.aspx</link><pubDate>Mon, 27 Jun 2005 19:54:00 GMT</pubDate><guid>http://davidhayden.com/blog/dave/archive/2005/06/27/1869.aspx</guid><description>&lt;P&gt;&lt;STRONG&gt;&lt;FONT face=Verdana size=2&gt;Summary&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;This post describes how the Strategy Design Pattern lets a variety of different algorithms be used interchangeably as well as&amp;nbsp;how it relates to the Dependency-Inversion Principle.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face=Verdana size=2&gt;Dependency-Inversion Principle&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;In a recent post I talked about the &lt;A href="http://davidhayden.com/blog/dave/archive/2005/06/10/1261.aspx"&gt;Dependency-Inversion Principle&lt;/A&gt; discussed in the the book, &lt;A href="http://davidhayden.com/blog/dave/category/42.aspx"&gt;Agile Software Development - Principles, Patterns, and Practices by Robert Martin&lt;/A&gt;.&amp;nbsp; The Dependency-Inversion Principle is one of five object-oriented programming principles associated with class design:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;FIELDSET&gt;&lt;LEGEND&gt;&lt;FONT face=Verdana size=2&gt;Dependency-Inversion Principle&lt;/FONT&gt;&lt;/LEGEND&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;A. High-level modules should not depend on low-level modules. Both should depend on abstractions.&lt;BR&gt;B. Abstractions should not depend on details. Details should depend on abstractions.&lt;/FONT&gt;&lt;/P&gt;&lt;/FIELDSET&gt;&lt;FONT face=Verdana size=2&gt; &lt;/FONT&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;The principle&amp;nbsp;suggests&amp;nbsp;you can make your applications loosely coupled (&lt;A href="http://davidhayden.com/blog/dave/archive/2004/12/14/690.aspx"&gt;Low Coupling GRASP Pattern&lt;/A&gt;) by not depending on concrete classes, but abstractions. This principle points out the direction of dependency on the abstraction. Rather than having the policy and business level classes dependent on the lower-level plumbing / utility type detail classes, it recommends that you invert the dependency and make the lower-level detail classes dependent on the higher level policy making classes that are most important in your application (via an abstraction).&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P align=center&gt;&lt;FONT face=Verdana size=2&gt;&lt;IMG src="http://www.davidhayden.com/photos/dependency-inversion%20principle.gif"&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;STRONG&gt;How This Relates to the Strategy Design Pattern&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Two design patterns that can help you&amp;nbsp;implement the Dependency-Inversion Principle in your applications&amp;nbsp;are the Template Method and Strategy Design Patterns.&amp;nbsp; These two&amp;nbsp;design patterns&amp;nbsp;are all about&amp;nbsp;hiding the specifics of an algorithm either via Inheritance (Template Method) or&amp;nbsp;delegation (Strategy Pattern).&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;The Strategy Design Pattern delegates algorithm specifics via an Interface.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;STRONG&gt;Example of Strategy Pattern in the .NET Framework&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;A great example of the Strategy Pattern in the .NET Framework is the sorting of objects in an ArrayList&amp;nbsp;via the &lt;A href="http://codebetter.com/blogs/david.hayden/archive/2005/03/06/56584.aspx"&gt;IComparer Interface&lt;/A&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;By default, the Sort method on ArrayList uses the QuickSort algorithm along with the &lt;A href="http://codebetter.com/blogs/david.hayden/articles/56094.aspx"&gt;IComparable implementation&amp;nbsp;of each&amp;nbsp;item&lt;/A&gt; in the list for sorting.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;However, at times it&amp;nbsp;may be necessary to sort the list in different ways. To accomplish this, there is an overload of Sort that takes an IComparer as a parameter.&amp;nbsp; If used, ArrayList&amp;nbsp;uses IComparer.Compare for the comparisons. By passing in an object that implements IComparer,&amp;nbsp;the ArrayList&amp;nbsp;can&amp;nbsp;implement other sorting&amp;nbsp;methods without caring about the details of the&amp;nbsp;comparison method.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;This is an example of the Strategy Design Pattern.&amp;nbsp; Hiding the details of the comparison method behind an Interface allows the algorithm to vary and keeps the ArrayList from being dependant on the classes that implement such algorithms.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;FIELDSET&gt;
&lt;P&gt;&lt;LEGEND&gt;&lt;FONT face=Verdana size=2&gt;Strategy Pattern with IComparer&lt;/FONT&gt;&lt;/LEGEND&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #0000ff"&gt;class&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; CoolComparer : IComparer
{
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;#region&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; IComparer Members&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;

    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; Compare(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;object&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; x, &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;object&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; y)
    {
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;//&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; TODO:  implementation&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt;0&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;;
    }

    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;#endregion&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;

}


ArrayList items &lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; ArrayList();

items.Add(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;One&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
items.Add(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;Two&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
items.Add(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008080"&gt;Three&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);

items.Sort(); &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;//&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; Uses IComparable on string object&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;
IComparer myComparer &lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; CoolComparer();
items.Sort(myComparer); &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;//&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; Delegate Comparison Method&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/FIELDSET&gt;&lt;FONT face=Verdana size=2&gt; &lt;/FONT&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face=Verdana size=2&gt;Conclusion&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;The Strategy Design Pattern is a pretty powerful and often used design pattern to loosely couple&amp;nbsp;your main classes in an&amp;nbsp;application from lower-level detail classes / algorithms.&amp;nbsp; As with all design patterns, it is best not to use them just for the sake of using them, because you will run the risk of needless complexity (&lt;A href="http://davidhayden.com/blog/dave/archive/2005/05/19/1029.aspx"&gt;application design smells&lt;/A&gt;)&amp;nbsp;in your applications.&amp;nbsp; They are best thought of as a solution to a &lt;A href="http://davidhayden.com/blog/dave/archive/2005/05/27/1054.aspx"&gt;real problem that occurs during refactoring and a method of communicating how the problem was solved&lt;/A&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;img src ="http://davidhayden.com/blog/dave/aggbug/1869.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Dave Hayden</dc:creator><title>Agile Software Development Principles, Patterns, and Practices Book Review Conclusion</title><link>http://davidhayden.com/blog/dave/archive/2005/06/17/1573.aspx</link><pubDate>Fri, 17 Jun 2005 13:40:00 GMT</pubDate><guid>http://davidhayden.com/blog/dave/archive/2005/06/17/1573.aspx</guid><description>&lt;P&gt;&lt;FONT face=Verdana size=2&gt;This post concludes&amp;nbsp;my &lt;/FONT&gt;&lt;A href="http://davidhayden.com/blog/dave/category/42.aspx"&gt;&lt;FONT face=Verdana size=2&gt;chapter-by-chapter review of Agile Software Development Principles, Patterns, and Practices by Robert Martin&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt;.&amp;nbsp; Although I have barely scratched the surface of the book in terms of posts and it certainly contains much more information (and more chapters) than I have presented in my review, I want to wrap this review up with the following comments below.&lt;/FONT&gt;&lt;/P&gt;
&lt;FIELDSET&gt;&lt;LEGEND&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;Agile Software Development, Principles, Patterns, and Practices&lt;/FONT&gt;&lt;/FONT&gt;&lt;/LEGEND&gt;
&lt;P&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;Book&lt;/STRONG&gt;: Agile Software Development, Principles, Patterns, and Practices (&lt;/FONT&gt;&lt;/FONT&gt;&lt;A href="http://www.amazon.com/exec/obidos/ASIN/0135974445/qid=1116531248/sr=2-1/ref=pd_bbs_b_2_1/002-3906371-8676026" target=_blank&gt;&lt;FONT face=Verdana size=2&gt;Amazon&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt;)&lt;BR&gt;&lt;STRONG&gt;Author&lt;/STRONG&gt;: Robert C. Martin (&lt;/FONT&gt;&lt;A href="http://www.amazon.com/exec/obidos/search-handle-url/index=books&amp;amp;field-author-exact=Robert%20C.%20Martin/002-3906371-8676026" target=_blank&gt;&lt;FONT face=Verdana size=2&gt;Amazon&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt;)&lt;BR&gt;&lt;STRONG&gt;Publisher&lt;/STRONG&gt;: Prentice Hall; 1st edition (October 15, 2002)&lt;BR&gt;&lt;STRONG&gt;Hardcover&lt;/STRONG&gt;: 552 pages&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Previous Chapters&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/05/16/1021.aspx"&gt;&lt;FONT face=Verdana size=2&gt;Chapters 1 - 4 - Agile Practices, XP, TDD&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt; &lt;/FONT&gt;
&lt;LI&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/05/18/1024.aspx"&gt;&lt;FONT face=Verdana size=2&gt;Chapters 5 and 6 - Refactoring and Pair Programming&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt; &lt;/FONT&gt;
&lt;LI&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/05/19/1029.aspx"&gt;&lt;FONT face=Verdana size=2&gt;Chapter 7 - What is Agile Design?&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt; &lt;/FONT&gt;
&lt;LI&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/05/29/1066.aspx"&gt;&lt;FONT face=Verdana size=2&gt;Chapter 8 - Single-Reponsibility Principle&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt; &lt;/FONT&gt;
&lt;LI&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/06/04/1096.aspx"&gt;&lt;FONT face=Verdana size=2&gt;Chapter 9 - Open-Closed Principle&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt; &lt;/FONT&gt;
&lt;LI&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/06/10/1226.aspx"&gt;&lt;FONT face=Verdana size=2&gt;Chapter 10 - The Liskov Substitution Principle&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt; &lt;/FONT&gt;
&lt;LI&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/06/10/1261.aspx"&gt;&lt;FONT face=Verdana size=2&gt;Chapter 11 - Dependency-Inversion Principle&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt; &lt;/FONT&gt;
&lt;LI&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/06/15/1482.aspx"&gt;&lt;FONT face=Verdana size=2&gt;Chapter 12 - Interface-Segregation Principle&lt;/FONT&gt;&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/FIELDSET&gt;&lt;FONT face=Verdana size=2&gt; &lt;/FONT&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face=Verdana size=2&gt;What I Didn't Cover&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;I didn't cover all the cool design patterns that Robert discusses in more detail&amp;nbsp;and how they relate to the five Object-Oriented Programming Class Design Principles mentioned above in Chapters 8 - 12.&amp;nbsp; Robert does an excellent job of describing the following design patterns and the rational behind them:&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;Command and Active Object&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;Template Method and Strategy&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;Facade and Mediator&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;Singleton and Monostate&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;Null Object&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;Factory&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;Composite&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;Observer&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;Abstract Server, Adapter, and Bridge&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;Proxy and Stairway to Heaven&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;Visitor&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;State&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;He also shows the design patterns being used in 3 case studies: Payroll Case Study, Weather Station Case Study, and an ETS Case Study.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face=Verdana size=2&gt;Conclusion&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Robert's book is an excellent introduction to object-oriented programming principles, design patterns, and how the theory can be used in a real application and application framework.&amp;nbsp; The information is well laid out in a logical and comfortable style.&amp;nbsp; Chapters can be easily digested in one-hour increments.&amp;nbsp; This is a good book for intermediate and expert developers.&amp;nbsp; Beginners with a bit of OOP experience will also benefit from reading the book.&amp;nbsp; For someone who hasn't done&amp;nbsp;any OOP at all, I am sure there are easier books to start out with.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;The code examples are in java and C++, so you won't find any C# or VB.NET examples and absolutely no mention of anything .NET related.&amp;nbsp; If you don't feel comfortable with looking at java or C++ syntax, I still think the book is a great buy with just the theory alone.&amp;nbsp; However, the code samples could definitely be improved, and they are certainly not one of the book's strengths.&amp;nbsp; If Robert came out with VB.NET and C# versions of the book, this book would be a must buy in my opinion.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face=Verdana size=2&gt;Book Resources&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://www.objectmentor.com/resources/listArticles?key=topic&amp;amp;topic=PPP" target=_blank&gt;&lt;FONT face=Verdana size=2&gt;Sample chapter downloads from the book&lt;/FONT&gt;&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://www.objectmentor.com/resources/listArticles?key=topic&amp;amp;topic=Design%20Principles" target=_blank&gt;&lt;FONT face=Verdana size=2&gt;Class design principles in PDF mentioned from the book&lt;/FONT&gt;&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face=Verdana size=2&gt;Recommended Companion Book&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://davidhayden.com/blog/dave/category/33.aspx?Show=All"&gt;&lt;FONT face=Verdana size=2&gt;Applying UML and Design Patterns - An Introduction to Object-Oriented Analysis and Design and Iterative Development by Craig Larman&lt;/FONT&gt;&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face=Verdana size=2&gt;Recommended Reading&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;MSDN Magazine July 2005 Article: &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/msdnmag/issues/05/07/DesignPatterns/default.aspx" target=_blank&gt;&lt;FONT face=Verdana size=2&gt;Discover the Design Patterns You're Already Using in the .NET Framework&lt;/FONT&gt;&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.conchango.com/howardvanrooijen/archive/2004/12/07/397.aspx" target=_blank&gt;&lt;FONT face=Verdana size=2&gt;The Value of Agile Methods - Slide Deck&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt; by Howard van Rooijen of conchango&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://www.patternshare.com/" target=_blank&gt;&lt;FONT face=Verdana size=2&gt;PatternShare&lt;/FONT&gt;&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://www.artima.com/lejava/articles/gammadp.html" target=_blank&gt;&lt;FONT face=Verdana size=2&gt;How to Use Design Patterns&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt; - A Conversation with Erich Gamma&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;img src ="http://davidhayden.com/blog/dave/aggbug/1573.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Dave Hayden</dc:creator><title>Interface-Segregation Principle (ISP) - Principles of Object-Oriented Design - Chapter 12 - Agile Software Development</title><link>http://davidhayden.com/blog/dave/archive/2005/06/15/1482.aspx</link><pubDate>Wed, 15 Jun 2005 11:25:00 GMT</pubDate><guid>http://davidhayden.com/blog/dave/archive/2005/06/15/1482.aspx</guid><description>&lt;P&gt;&lt;FONT face=Verdana size=2&gt;This&amp;nbsp;post&amp;nbsp;describes the last of&amp;nbsp;the 5 Class Design Principles&amp;nbsp;associated with the Principles of Object-Oriented Design. You can read all&amp;nbsp;the posts from&amp;nbsp;my &lt;/FONT&gt;&lt;A href="http://davidhayden.com/blog/dave/category/42.aspx"&gt;&lt;FONT face=Verdana size=2&gt;chapter-by-chapter review of Agile Software Development Principles, Patterns, and Practices by Robert Martin&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;FIELDSET&gt;&lt;LEGEND&gt;&lt;FONT size=2&gt;Agile Software Development, Principles, Patterns, and Practices&lt;/FONT&gt;&lt;/LEGEND&gt;
&lt;P&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;Book&lt;/STRONG&gt;: Agile Software Development, Principles, Patterns, and Practices (&lt;A href="http://www.amazon.com/exec/obidos/ASIN/0135974445/qid=1116531248/sr=2-1/ref=pd_bbs_b_2_1/002-3906371-8676026" target=_blank&gt;Amazon&lt;/A&gt;)&lt;BR&gt;&lt;STRONG&gt;Author&lt;/STRONG&gt;: Robert C. Martin (&lt;A href="http://www.amazon.com/exec/obidos/search-handle-url/index=books&amp;amp;field-author-exact=Robert%20C.%20Martin/002-3906371-8676026" target=_blank&gt;Amazon&lt;/A&gt;)&lt;BR&gt;&lt;STRONG&gt;Publisher&lt;/STRONG&gt;: Prentice Hall; 1st edition (October 15, 2002)&lt;BR&gt;&lt;STRONG&gt;Hardcover&lt;/STRONG&gt;: 552 pages&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Previous Chapters&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/05/16/1021.aspx"&gt;Chapters 1 - 4 - Agile Practices, XP, TDD&lt;/A&gt;&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/05/18/1024.aspx"&gt;Chapters 5 and 6 - Refactoring and Pair Programming&lt;/A&gt;&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/05/19/1029.aspx"&gt;Chapter 7 - What is Agile Design?&lt;/A&gt;&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/05/29/1066.aspx"&gt;Chapter 8 - Single-Reponsibility Principle&lt;/A&gt;&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/06/04/1096.aspx"&gt;Chapter 9 - Open-Closed Principle&lt;/A&gt;&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/06/10/1226.aspx"&gt;Chapter 10 - The Liskov Substitution Principle&lt;/A&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/06/10/1261.aspx"&gt;Chapter 11 - Dependency-Inversion Principle&lt;/A&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/FIELDSET&gt;&lt;FONT face=Verdana size=2&gt; &lt;/FONT&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Chapter 12 is on the &lt;STRONG&gt;Interface-Segregation Principle (ISP)&lt;/STRONG&gt;:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;FIELDSET&gt;&lt;LEGEND&gt;Interface-Segregation Principle&lt;/LEGEND&gt;
&lt;P&gt;Clients should not be forced to depend on methods that they do not use.&lt;/P&gt;&lt;/FIELDSET&gt;&lt;FONT face=Verdana size=2&gt; &lt;/FONT&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;This principle is very much related to the &lt;/FONT&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2004/12/10/680.aspx"&gt;&lt;FONT face=Verdana size=2&gt;High Cohesion GRASP Pattern&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2004/12/10/680.aspx"&gt;&lt;FONT face=Verdana size=2&gt;High Cohesion GRASP Pattern&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt; - how strongly related and focused the responsibilities of an object are&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;The Interface-Segregation Principle focuses on the cohesiveness of interfaces with respect to the clients that use them.&amp;nbsp; Here are some other descriptions I found while Googling:&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;&amp;#8220;Many client specific interfaces are better than one general purpose interface&amp;#8220;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;&amp;#8220;The dependency of one class to another one should depend on the smallest possible interface&amp;#8220;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;&amp;#8220;Make fine grained interfaces that are client specific.&amp;#8220;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;&amp;#8220;Clients should not be forced to depend upon interfaces that they don&amp;#8217;t use. This principle deals with the disadvantages of fat interfaces. Fat interfaces are not cohesive. In other words the interfaces of classes should be broken into groups of member functions.&amp;#8220;&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;The idea here is that each client may use a particular object or subsystem in a different way.&amp;nbsp; Take an inventory system for example.&amp;nbsp; Your e-commerce website may only check on the inventory status of a product, but your order fulfillment system&amp;nbsp;may both check on the status of a product&amp;nbsp;as well as&amp;nbsp;manipulate inventory levels.&amp;nbsp; This&amp;nbsp;suggests that you will probably want to have 1 interface for checking product inventory levels and another interface for manipulating inventory levels.&amp;nbsp; This will keep each client&amp;nbsp;independent of interfaces that they do not use.&amp;nbsp; If you need to change one interface, you shouldn't need to change the other. As you create your application and identify the particular clients and user stories, these cohesive interfaces will become evident.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Robert had a couple examples of the Interface-Segregation Principle.&amp;nbsp; The more interesting one was about an ATM, where it may logically stand to reason that you may have separate interefaces for a person conducting a 1) Deposit Transaction, 2) Withdrawal Transaction, and 3) Transfer Transaction.&amp;nbsp; You would definitely separate these 3 interfaces from each other so that one type of transaction does not depend on functions it does not need.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;You can read Robert's words about the&amp;nbsp;Interface-Segregation Principle&amp;nbsp;in this &lt;/FONT&gt;&lt;A href="http://www.objectmentor.com/resources/articles/isp.pdf" target=_blank&gt;&lt;FONT face=Verdana size=2&gt;PDF&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt;.&lt;/FONT&gt;&lt;/P&gt;&lt;img src ="http://davidhayden.com/blog/dave/aggbug/1482.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Dave Hayden</dc:creator><title>The Dependency-Inversion Principle - Chapter 11 - Agile Software Development Principles Patterns and Practices</title><link>http://davidhayden.com/blog/dave/archive/2005/06/10/1261.aspx</link><pubDate>Fri, 10 Jun 2005 14:50:00 GMT</pubDate><guid>http://davidhayden.com/blog/dave/archive/2005/06/10/1261.aspx</guid><description>&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Moving along with&amp;nbsp;my &lt;/FONT&gt;&lt;A href="http://davidhayden.com/blog/dave/category/42.aspx"&gt;&lt;FONT face=Verdana size=2&gt;chapter-by-chapter review of Agile Software Development Principles, Patterns, and Practices by Robert Martin&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;FIELDSET&gt;&lt;LEGEND&gt;&lt;FONT size=2&gt;Agile Software Development, Principles, Patterns, and Practices&lt;/FONT&gt;&lt;/LEGEND&gt;
&lt;P&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;Book&lt;/STRONG&gt;: Agile Software Development, Principles, Patterns, and Practices (&lt;A href="http://www.amazon.com/exec/obidos/ASIN/0135974445/qid=1116531248/sr=2-1/ref=pd_bbs_b_2_1/002-3906371-8676026" target=_blank&gt;Amazon&lt;/A&gt;)&lt;BR&gt;&lt;STRONG&gt;Author&lt;/STRONG&gt;: Robert C. Martin (&lt;A href="http://www.amazon.com/exec/obidos/search-handle-url/index=books&amp;amp;field-author-exact=Robert%20C.%20Martin/002-3906371-8676026" target=_blank&gt;Amazon&lt;/A&gt;)&lt;BR&gt;&lt;STRONG&gt;Publisher&lt;/STRONG&gt;: Prentice Hall; 1st edition (October 15, 2002)&lt;BR&gt;&lt;STRONG&gt;Hardcover&lt;/STRONG&gt;: 552 pages&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Previous Chapters&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/05/16/1021.aspx"&gt;Chapters 1 - 4 - Agile Practices, XP, TDD&lt;/A&gt;&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/05/18/1024.aspx"&gt;Chapters 5 and 6 - Refactoring and Pair Programming&lt;/A&gt;&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/05/19/1029.aspx"&gt;Chapter 7 - What is Agile Design?&lt;/A&gt;&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/05/29/1066.aspx"&gt;Chapter 8 - Single-Reponsibility Principle&lt;/A&gt;&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/06/04/1096.aspx"&gt;Chapter 9 - Open-Closed Principle&lt;/A&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/06/10/1226.aspx"&gt;Chapter 10 - The Liskov Substitution Principle&lt;/A&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/FIELDSET&gt;&lt;FONT face=Verdana size=2&gt; &lt;/FONT&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Chapter 11 is on the &lt;STRONG&gt;Dependency-Inversion Principle&lt;/STRONG&gt;:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;FIELDSET&gt;&lt;LEGEND&gt;Dependency-Inversion Principle&lt;/LEGEND&gt;
&lt;P&gt;A. High-level modules should not depend on low-level modules. Both should depend on abstractions.&lt;BR&gt;B. Abstractions should not depend on details. Details should depend on abstractions.&lt;/P&gt;&lt;/FIELDSET&gt;&lt;FONT face=Verdana size=2&gt; &lt;/FONT&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;This principle is closely related&amp;nbsp;to two other principles that I have talked about previously:&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/06/04/1096.aspx"&gt;&lt;FONT face=Verdana size=2&gt;Open-Closed Principle&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt; - Modules should be open for extension, but closed for modification.&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2004/12/14/690.aspx"&gt;&lt;FONT face=Verdana size=2&gt;Low Coupling GRASP Pattern&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt; - An element with low (or weak) coupling is not dependent on too many other elements.&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;All three of these principles have to do with making your applications loosely coupled by not depending on concrete classes when appropriate, but abstractions.&amp;nbsp; These abstractions are usually done with abstract classes and interfaces. This book has tended to focus on abstract classes, but you can find other books that prefer interfaces, etc.&amp;nbsp; There are pros and cons to each, and that subject is beyond the scope of this post :).&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;This principle is unique with respect to the others in that it points out the direction of dependency on the abstraction. Rather than having the policy and business level classes dependent on the lower-level plumbing / utility type detail classes, it recommends that you invert the dependency and make the lower-level detail classes dependent on the higher level policy making classes that are most important in your application (via an abstraction).&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Robert said it best in this brief, well-written chunk of text from his book:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&amp;#8220;Consider the implications of high level modules that depend upon low level modules. It is the high level modules that contain the important policy decisions and business models of an application. It is these models that contain the identity of the application. Yet, when these modules depend upon the lower level modules, then changes to the lower level modules can have direct effects upon them; and can force them to change.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;This predicament is absurd! It is the high level modules that ought to be forcing the low level modules to change. It is the high level modules that should take precedence over the lower level modules. High level modules simply should not depend upon low level modules in any way.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Moreover, it is high level modules that we want to be able to reuse. We are already quite good at reusing low level modules in the form of subroutine libraries. When high level modules depend upon low level modules, it becomes very difficult to reuse those high level modules in different contexts. However, when the high level modules are independent of the low level modules, then the high level modules can be reused quite simply.[Martin, p.127-128]&amp;#8221;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;You can see this visually in the following figures:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P align=center&gt;&lt;FONT face=Verdana size=2&gt;&lt;IMG src="http://www.davidhayden.com/photos/dependency-inversion%20principle.gif"&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;This is a very, very common practice.&amp;nbsp; Everything in the &lt;/FONT&gt;&lt;A href="http://codebetter.com/blogs/david.hayden/articles/category/1094.aspx" target=_blank&gt;&lt;FONT face=Verdana size=2&gt;Enterprise Library Application Block&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt; uses this principle to make it pluggable so that you can add new caching strategies, data repositories, configuration policies, etc. It is also used in anything that uses the Provider Model, because this is the basis of the Provider Model - provide an abstraction in the .NET framework that your application can utilize and have components that provide the detail be dependent on that abstraction used in your application.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;You can see my&amp;nbsp;posts on DotNetNuke and Community Server for a little bit of information on the &lt;/FONT&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/04/27/993.aspx"&gt;&lt;FONT face=Verdana size=2&gt;Provider Model&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt; - the pre&amp;nbsp;.NET 2.0 version anyway, which I have used several times in applications:&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/04/01/918.aspx"&gt;&lt;FONT face=Verdana size=2&gt;Community Server Source Code - Abstract Classes, Reflection and Data Providers&lt;/FONT&gt;&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/04/03/933.aspx"&gt;&lt;FONT face=Verdana size=2&gt;DotNetNuke Architecture - Digging Into the DNN Source Code&lt;/FONT&gt;&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;You can read Robert's words about the Dependency-Inversion Principle in this &lt;/FONT&gt;&lt;A href="http://www.objectmentor.com/resources/articles/dip.pdf" target=_blank&gt;&lt;FONT face=Verdana size=2&gt;PDF&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt;. A couple of chapters from now I will start digging into a lot of the &lt;A href="http://davidhayden.com/blog/dave/category/22.aspx"&gt;Design Patterns&lt;/A&gt; that support these principles.&lt;/FONT&gt;&lt;/P&gt;&lt;img src ="http://davidhayden.com/blog/dave/aggbug/1261.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Dave Hayden</dc:creator><title>The Liskov Substitution Principle - Agile Software Development Principles Patterns and Practices</title><link>http://davidhayden.com/blog/dave/archive/2005/06/10/1226.aspx</link><pubDate>Fri, 10 Jun 2005 10:53:00 GMT</pubDate><guid>http://davidhayden.com/blog/dave/archive/2005/06/10/1226.aspx</guid><description>&lt;P&gt;&lt;FONT face=Verdana size=2&gt;For the past few weeks I have been doing a &lt;/FONT&gt;&lt;A href="http://davidhayden.com/blog/dave/category/42.aspx"&gt;&lt;FONT face=Verdana size=2&gt;chapter-by-chapter review of Agile Software Development Principles, Patterns, and Practices by Robert Martin&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt;.&amp;nbsp; So far, it has covered a lot of good introductory information on various Agile Methodologies (Test-Driven Development, Refactoring, Pair Programming, Project Planning, Extreme Programming, etc.) as well as talked about various object-oriented programming principles, which is what I am still covering now.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Here is a chapter-by-chapter breakdown on what I have covered so far:&lt;/FONT&gt;&lt;/P&gt;
&lt;FIELDSET&gt;&lt;LEGEND&gt;&lt;FONT size=2&gt;Agile Software Development, Principles, Patterns, and Practices&lt;/FONT&gt;&lt;/LEGEND&gt;
&lt;P&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;Book&lt;/STRONG&gt;: Agile Software Development, Principles, Patterns, and Practices (&lt;A href="http://www.amazon.com/exec/obidos/ASIN/0135974445/qid=1116531248/sr=2-1/ref=pd_bbs_b_2_1/002-3906371-8676026" target=_blank&gt;Amazon&lt;/A&gt;)&lt;BR&gt;&lt;STRONG&gt;Author&lt;/STRONG&gt;: Robert C. Martin (&lt;A href="http://www.amazon.com/exec/obidos/search-handle-url/index=books&amp;amp;field-author-exact=Robert%20C.%20Martin/002-3906371-8676026" target=_blank&gt;Amazon&lt;/A&gt;)&lt;BR&gt;&lt;STRONG&gt;Publisher&lt;/STRONG&gt;: Prentice Hall; 1st edition (October 15, 2002)&lt;BR&gt;&lt;STRONG&gt;Hardcover&lt;/STRONG&gt;: 552 pages&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Previous Chapters&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/05/16/1021.aspx"&gt;Chapters 1 - 4 - Agile Practices, XP, TDD&lt;/A&gt;&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/05/18/1024.aspx"&gt;Chapters 5 and 6 - Refactoring and Pair Programming&lt;/A&gt;&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/05/19/1029.aspx"&gt;Chapter 7 - What is Agile Design?&lt;/A&gt;&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/05/29/1066.aspx"&gt;Chapter 8 - Single-Reponsibility Principle&lt;/A&gt;&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/06/04/1096.aspx"&gt;Chapter 9 - Open-Closed Principle&lt;/A&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/FIELDSET&gt;&lt;FONT face=Verdana size=2&gt; &lt;/FONT&gt;
&lt;P&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&amp;nbsp;Chapter 10 is on the &lt;STRONG&gt;Liskov Substitution Principle:&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;FIELDSET&gt;&lt;LEGEND&gt;Liskov Substitution Principle&lt;/LEGEND&gt;
&lt;P&gt;&amp;#8220;What is wanted is something like the following substitution property: If for each object o1 of type S there is an object o2 of type T such that for all programs P defined in terms of T, the behavior of P is unchanged when o1 is substituted for o2, then S is a subtype of T. [Liskov88]&amp;#8220;&lt;/P&gt;&lt;/FIELDSET&gt;&lt;FONT face=Verdana size=2&gt; &lt;/FONT&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Is it me, or is&amp;nbsp;that painful to read?&amp;nbsp; Robert Martin puts it a bit simpler:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face=Verdana size=2&gt;Subtypes must be substitutable for their base types&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;The classic example of this principle in code is&amp;nbsp;inheriting the &lt;STRONG&gt;Square&lt;/STRONG&gt; Class from the &lt;STRONG&gt;Rectangle&lt;/STRONG&gt; Class.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;FIELDSET&gt;&lt;LEGEND&gt;Classic Example of LSP&lt;/LEGEND&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;class&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; Rectangle
{
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;protected&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; _width;
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;protected&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; _height;
    
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; Width
    {
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;get&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; { &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; _width; }
    }
    
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; Height
    {
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;get&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; { &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; _height; }
    }
    
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;virtual&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;void&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; SetWidth(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; width)
    {
        _width &lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; width;
    }
    
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;virtual&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;void&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; SetHeight(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; height)
    {
        _height &lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; height;
    }
}

&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;class&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; Square: Rectangle
{
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;override&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;void&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; SetWidth(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; width)
    {
        _width &lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; width;
        _height &lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; width;
    }
    
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;override&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;void&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; SetHeight(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; height)
    {
        _height &lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; height;
        _width &lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; _height;
    }
}

[TestFixture]
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;class&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; RectangleTests
{
    [Test]
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;void&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; AreaOfRectangle()
    {
        Rectangle r &lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; Square();
        
        r.Width &lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt;5&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;;
        r.Height &lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt;2&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;;
        
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;//&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; Will Fail - r is a square and sets
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;//&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt; width and height equal to each other.&lt;/SPAN&gt;&lt;SPAN style="COLOR: #008000"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;        Assert.IsEqual(r.Width &lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;*&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt; r.Height,&lt;/SPAN&gt;&lt;SPAN style="COLOR: #ff0000"&gt;10&lt;/SPAN&gt;&lt;SPAN style="COLOR: #000000"&gt;);
    }
}&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/FIELDSET&gt;&lt;FONT face=Verdana size=2&gt; &lt;/FONT&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;If you look at the test above, it will fail because a square is being substituted for a rectangle and the area won't be 10 as expected.&amp;nbsp; It will actually be 4 because &amp;#8220;unexpectedly&amp;#8221; in this case, both height and width are being set to each other when the width or height is set on a square.&amp;nbsp; Therefore, if this behavior by Square is unacceptable and unexpected, Square should not be derived from&amp;nbsp;Rectangle (at least not coded like this with these expectations anyway).&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;This is the whole point of the &lt;STRONG&gt;Liskov Substitution Principle&lt;/STRONG&gt;.&amp;nbsp; It basically wants you to think clearly about the expected behavior and expectations of a class before you derive new classes from it.&amp;nbsp; It could turn out that when subtypes are substituted for&amp;nbsp;a parent, you may get unexpected results.&amp;nbsp; This is where unit tests can really be handy.&amp;nbsp; The unit tests essentially describe and test for the expected behavior of objects (design by contract, if you will).&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;If you want to read some discussions as to the usefulness of this principle, whether it should be a principle, and&amp;nbsp;thoughts on&amp;nbsp;the classic example above, check out this &lt;/FONT&gt;&lt;A href="http://c2.com/cgi/wiki?LiskovSubstitutionPrinciple" target=_blank&gt;&lt;FONT face=Verdana size=2&gt;wiki&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt;.&amp;nbsp; You can also read what Robert Martin has to say about it from this &lt;/FONT&gt;&lt;A href="http://www.objectmentor.com/resources/articles/lsp.pdf" target=_blank&gt;&lt;FONT face=Verdana size=2&gt;PDF&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt;.&lt;/FONT&gt;&lt;/P&gt;&lt;img src ="http://davidhayden.com/blog/dave/aggbug/1226.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Dave Hayden</dc:creator><title>Open-Closed Principle (OCP) - Agile Software Development - Object-Oriented Principles and Software Development</title><link>http://davidhayden.com/blog/dave/archive/2005/06/04/1096.aspx</link><pubDate>Sat, 04 Jun 2005 20:15:00 GMT</pubDate><guid>http://davidhayden.com/blog/dave/archive/2005/06/04/1096.aspx</guid><description>&lt;P&gt;&lt;FONT face=Verdana size=2&gt;It's been raining all week in Sarasota, Florida and all day long today.&amp;nbsp; Perfect weather for playing inside with the kids, watching movies I would never normally watch, and sipping on &lt;/FONT&gt;&lt;A href="http://www.relaxsipenjoy.com/special_teas.aspx" target=_blank&gt;&lt;FONT face=Verdana size=2&gt;green tea&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt; while reading a good book, &lt;/FONT&gt;&lt;A href="http://davidhayden.com/blog/dave/category/42.aspx"&gt;&lt;FONT face=Verdana size=2&gt;Agile Software Development Principles, Patterns, and Practices&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt;, by Robert C. Martin (&lt;/FONT&gt;&lt;A href="http://www.amazon.com/exec/obidos/tg/detail/-/0135974445/103-7264512-4567047?v=glance" target=_blank&gt;&lt;FONT face=Verdana size=2&gt;Amazon&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt;).&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;I have completed 9 chapters of this 30 chapter book and have enjoyed it tremendously.&amp;nbsp; So far, I would highly recommend it for someone interested in reading about&amp;nbsp;solid OOP principles and guidelines for developing software.&amp;nbsp;&amp;nbsp;I enjoy&amp;nbsp;reading these good practices from a number of different books with different styles and examples because it helps reinforce the information as well as perhaps opens new insights.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Here are the chapters I have read so far:&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;Chapter 1 - 4: &lt;/FONT&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/05/16/1021.aspx"&gt;&lt;FONT face=Verdana size=2&gt;Agile Practices, Extreme Programming, and Test-Driven Development&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt; &lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;Chapter 5 and 6: &lt;/FONT&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/05/18/1024.aspx"&gt;&lt;FONT face=Verdana size=2&gt;Refactoring and Pair Programming&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt; &lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;Chapter 7: &lt;/FONT&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/05/19/1029.aspx"&gt;&lt;FONT face=Verdana size=2&gt;Agile Design&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt; &lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;Chapter 8: &lt;/FONT&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/05/29/1066.aspx"&gt;&lt;FONT face=Verdana size=2&gt;Single-Responsibility Principle&lt;/FONT&gt;&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Chapter 9 is on the &lt;STRONG&gt;Open-Closed Principle&lt;/STRONG&gt;:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;FIELDSET&gt;&lt;LEGEND&gt;Open-Closed Principle&lt;/LEGEND&gt;
&lt;P&gt;"Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification [Martin, p.99]"&lt;/P&gt;&lt;/FIELDSET&gt;&lt;FONT face=Verdana size=2&gt; &lt;/FONT&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;The author goes on to explain that this principle encourages the developer to refactor (&lt;/FONT&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/05/28/1061.aspx"&gt;&lt;FONT face=Verdana size=2&gt;MSDN Refactoring Webcast&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt;) the software such that if enhancements&amp;nbsp;or changes are required at a later time, it only requires the developer to add new code, not change exisiting code.&amp;nbsp; This is a rather cool idea, because it means that maintaing software in the future should be easier as you don't have to worry as much about breaking existing code.&amp;nbsp; Forgetting for a moment whether this notion is realistic or even achievable, it is a good thing to shoot for in your applications.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Robert Martin says modules that adhere to this Open-Closed Principle have 2 primary attributes:&lt;/FONT&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;"&lt;STRONG&gt;Open For Extension&lt;/STRONG&gt;" - It is possible to extend the behavior of the module as the requirements of the application change (i.e. change the behavior of the module). &lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana size=2&gt;"&lt;STRONG&gt;Closed For Modification&lt;/STRONG&gt;" - Extending the behavior of the module does not result in the changing of the source code or binary code of the module itself.&lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;At first glance, these two attributes seem to be at odds.&amp;nbsp; However, as I read further through the chapter, I realize he is referring to using &lt;STRONG&gt;Abstract Classes&lt;/STRONG&gt; and their &lt;STRONG&gt;Concrete SubClasses&lt;/STRONG&gt; to extend behavior.&amp;nbsp; This essentially means using something like the &lt;STRONG&gt;Template Method Pattern&lt;/STRONG&gt; or &lt;STRONG&gt;Strategy Pattern&lt;/STRONG&gt; to delegate either part or all of an algorithm in a Concrete SubClass.&amp;nbsp; The Template Method Pattern UML is shown below:&lt;/FONT&gt;&lt;/P&gt;
&lt;P align=center&gt;&lt;FONT face=Verdana size=2&gt;&lt;IMG src="http://www.davidhayden.com/photos/template-method.gif"&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;A Template Method is a Method in an (abstract) base class which calls one or more HookMethods to fulfill parts of its tasks.&amp;nbsp; You can easily extend or change the behavior of the abstract base class by creating new subclasses that implement a new version of the Hook Method.&amp;nbsp; This fulfills the requirements of the Open-Closed Principle.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Every good application is probably teeming with abstract base classes for this very thing, and I know of 3 open-source applications I have recently talked about where you can find it:&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;DotNetNuke&lt;/STRONG&gt; - &lt;/FONT&gt;&lt;/FONT&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/04/27/993.aspx"&gt;&lt;FONT face=Verdana size=2&gt;Provider model&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt; for the data access layer &lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;Community Server&lt;/STRONG&gt; - &lt;/FONT&gt;&lt;/FONT&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/04/27/993.aspx"&gt;&lt;FONT face=Verdana size=2&gt;Provider model&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt; for the data access layer &lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;Enterprise Library&lt;/STRONG&gt; - Used&amp;nbsp;in every application block to add new functionality.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Each of the open-source applications use modules supporting the &lt;STRONG&gt;Open-Closed Principle&lt;/STRONG&gt; to allow them to plug either 1) a new data provider in the case of &lt;STRONG&gt;DotNetNuke&lt;/STRONG&gt; and &lt;STRONG&gt;Community Server&lt;/STRONG&gt;, or 2) a new caching strategy (as an example) &amp;nbsp;for the &lt;STRONG&gt;Enterprise Library&lt;/STRONG&gt;.&amp;nbsp; This extensability is achieved using a pluggable architecture&amp;nbsp;that uses reflection and configuration files, which is one way to achieve the "Open For Extension" but "Closed For Modifications" idea of the Open-Closed Principle.&lt;/FONT&gt;&lt;/P&gt;&lt;img src ="http://davidhayden.com/blog/dave/aggbug/1096.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Dave Hayden</dc:creator><title>Single-Responsibility Principle - Agile Software Development Principles Patterns and Practices</title><link>http://davidhayden.com/blog/dave/archive/2005/05/29/1066.aspx</link><pubDate>Sun, 29 May 2005 17:02:00 GMT</pubDate><guid>http://davidhayden.com/blog/dave/archive/2005/05/29/1066.aspx</guid><description>&lt;P&gt;&lt;FONT face=Verdana size=2&gt;I am continuing my reading of &lt;/FONT&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/05/16/1021.aspx"&gt;&lt;FONT face=Verdana size=2&gt;Agile Software Development - Principles, Patterns, and Practices&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt; by Robert C. Martin (&lt;/FONT&gt;&lt;A href="http://www.amazon.com/exec/obidos/ASIN/0135974445/qid=1117390694/sr=2-1/ref=pd_bbs_b_2_1/103-2296746-1991852" target=_blank&gt;&lt;FONT face=Verdana size=2&gt;Amazon&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt;).  Chapter 8 talks about the Single-Responsibility Principle:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;/FONT&gt; &lt;/P&gt;
&lt;FIELDSET&gt;&lt;LEGEND&gt;Single-Responsibility Principle&lt;/LEGEND&gt;
&lt;P&gt;A class should have only one reason to change.&lt;/P&gt;&lt;/FIELDSET&gt;&lt;FONT face=Verdana size=2&gt; &lt;/FONT&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;As the chapter explains, the &lt;STRONG&gt;single-responsibility principle&lt;/STRONG&gt; is more frequently known as &lt;STRONG&gt;cohesion&lt;/STRONG&gt; (&lt;/FONT&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2004/12/10/680.aspx"&gt;&lt;FONT face=Verdana size=2&gt;High Cohesion GRASP Pattern&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt;), which is the functional relatedness of the elements of a module.  Basically, you want to keep classes, functions, etc. focused so that there is only one reason for them to change.  This is the reason why many people &lt;/FONT&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2004/12/12/685.aspx"&gt;&lt;FONT face=Verdana size=2&gt;separate their applications into layers&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt;, for example.  The data access layer provides persistence and re-hydration of business objects.  The business layer is all about business rules.  And, the presentation layer is only about presenting information to the user.  Hopefully a change in one layer won't cause a ripple effect of changes in other layers, or at least, keep the impact to a minimum.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Robert provides a couple of examples in the brief  3 page chapter.  A popular example that "violates" this principle is placing persistence logic in your business classes.  By doing so, you have 2 reasons for a business class to change.  First, when you need to change the persistence logic, and second, when you need to change the business rules.  Fowler describes this type of domain model as &lt;STRONG&gt;Active Record&lt;/STRONG&gt; (&lt;/FONT&gt;&lt;A href="http://www.martinfowler.com/eaaCatalog/activeRecord.html" target=_blank&gt;&lt;FONT face=Verdana size=2&gt;details&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt;), and although it violates this principle, Active Record is successfully used in many applications.  These principles are only guidelines and you have to weigh the pros and cons of following these guidelines as all of them impact time of delivery, cost, and maintainability.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;However, the author reinforces that we should be thinking about "real" changes - focusing on things that most likely could change.  If you don't see your data access logic changing, then Active Record may not be violating this principle at all.  So many people build their applications so that they can switch databases, swich persistence logic, etc., but in reality this may not happen.  So, when we look at these axis of change for a particular class, function, layer, etc., the author stresses to only focus on those pieces that really could change.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;A good example of sticking to this principle could be found in an off-the-shelf, e-commerce application.  When calculating shipping costs on a particular sale, the developers of the e-commerce application don't want the Sale class calculating shipping costs.  Each online store has their own rules for calculating shipping costs on a sale, and the developers would want shipping costs calculated by a separate class that contains the business rules for each store.  By placing shipping calculations in a separate class, the Sale class does not have to change everytime the shipping calculations change.  As a result, shipping calculations are usually placed in separate, pluggable classes that implement the Strategy Pattern.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;So far, the book is excellent and you might be interesting in reading about other chapters:&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/05/16/1021.aspx"&gt;&lt;FONT face=Verdana size=2&gt;Chapters 1 - 4 - Agile Practices, XP, TDD&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt; &lt;/FONT&gt;
&lt;LI&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/05/18/1024.aspx"&gt;&lt;FONT face=Verdana size=2&gt;Chapters 5 and 6 - Refactoring and Pair Programming&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt; &lt;/FONT&gt;
&lt;LI&gt;&lt;A href="http://davidhayden.com/blog/dave/archive/2005/05/19/1029.aspx"&gt;&lt;FONT face=Verdana size=2&gt;Chapter 7 - What is Agile Design?&lt;/FONT&gt;&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;As I mentioned before, you can read about this principle &lt;/FONT&gt;&lt;A href="http://www.butunclebob.com/ArticleS.UncleBob.PrinciplesOfObjectOrientedDesign" target=_blank&gt;&lt;FONT face=Verdana size=2&gt;here&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana size=2&gt; on the author's website.&lt;/FONT&gt;&lt;/P&gt;&lt;img src ="http://davidhayden.com/blog/dave/aggbug/1066.aspx" width = "1" height = "1" /&gt;</description></item></channel></rss>