CSC/ECE 517 Fall 2012/ch2b 2w64 bg: Difference between revisions
(27 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
= | =Overview= | ||
The Internet is the new and the biggest source of information today. The Internet is so overwhelmed with information that sometimes it is difficult to find the exact things. So the purpose of this Wikipedia page is to give the readers a list of references that explain the Strategy pattern and all the details about its implementation and working. The references given in this page will give a complete knowledge of this pattern. Further, with each references given in this page a briefing of what it covers, the programming language used and the purpose that it serves is mentioned. | |||
Strategy Pattern is a software design pattern that can be used to select a particular algorithm among many available ones at run time depending on certain conditions. A clear definition of the Strategy Pattern can be found [http://en.wikipedia.org/wiki/Strategy_pattern here]. This resource gives a general idea of the pattern, a useful reference for readers that have not used this pattern before. The reference is written in a simple and easily understandable way that can be beneficial for a new reader as well as the programmers that want to have a very high level idea about the pattern. It includes a pictorial representation of the fundamental concept behind the pattern and explains it using an example in Java. This resource includes a discussion about the Open/Close principle and relates it with the Strategy pattern. | =Strategy Pattern and a Directory of sites= | ||
Strategy Pattern[http://en.wikipedia.org/wiki/Strategy_pattern] is a software design pattern [http://en.wikipedia.org/wiki/Software_design_patterns] that can be used to select a particular algorithm[http://en.wikipedia.org/wiki/Algorithm] among many available ones at run time depending on certain conditions. A clear definition of the Strategy Pattern can be found [http://en.wikipedia.org/wiki/Strategy_pattern here]. This resource gives a general idea of the pattern, a useful reference for readers that have not used this pattern before. The reference is written in a simple and easily understandable way that can be beneficial for a new reader as well as the programmers that want to have a very high level idea about the pattern. It includes a pictorial representation of the fundamental concept behind the pattern and explains it using an example in Java[http://en.wikipedia.org/wiki/Java_(programming_language)]. This resource includes a discussion about the Open/Close principle[http://en.wikipedia.org/wiki/Open/closed_principle] and relates it with the Strategy pattern. | |||
=Strategy Pattern, Getting Started= | =Strategy Pattern, Getting Started= | ||
Line 8: | Line 12: | ||
Now that you know the basic definitions and concept of the Strategy pattern, [http://www.oodesign.com/strategy-pattern.html this] will give a deeper insight into the pattern. It explains the motivation behind using the Strategy Pattern and various situations where strategy pattern is useful. A Java example is used to provide better understanding of the concept. Further, it adds some details with regard to implementing a Strategy Pattern such as passing data. It includes a discussion about other patterns that are related to the Strategy pattern. | Now that you know the basic definitions and concept of the Strategy pattern, [http://www.oodesign.com/strategy-pattern.html this] will give a deeper insight into the pattern. It explains the motivation behind using the Strategy Pattern and various situations where strategy pattern is useful. A Java example is used to provide better understanding of the concept. Further, it adds some details with regard to implementing a Strategy Pattern such as passing data. It includes a discussion about other patterns that are related to the Strategy pattern. | ||
To gain further insight into the working of the Strategy Pattern, [http://www.codeproject.com/Articles/52807/Design-Patterns-Part-1-The-Strategy-Pattern this] resource gives a precise description with well accompanied example. The example is in C# and is very descriptive and easy to understand. The author of the article has shown how to apply the Strategy Pattern to solve a real problem. Additionally, it discusses some of the implementation problems associated with this pattern. This is a good extension to the previous resource. | To gain further insight into the working of the Strategy Pattern, [http://www.codeproject.com/Articles/52807/Design-Patterns-Part-1-The-Strategy-Pattern this] resource gives a precise description with well accompanied example. The example is in C# [http://en.wikipedia.org/wiki/C_Sharp_(programming_language)]and is very descriptive and easy to understand. The author of the article has shown how to apply the Strategy Pattern to solve a real problem. Additionally, it discusses some of the implementation problems associated with this pattern. This is a good extension to the previous resource. | ||
Patterns make the code better readable and easy to maintain. There are some difficulties <ref name="Difficulties"> http://www.javaworld.com/javaworld/jw-04-2002/jw-0426-designpatterns.html </ref> when design pattern are not used. This reference gives a comprehensive idea on the disadvantages of not using a design pattern and how the code becomes readable and easy after using the strategy pattern. This resource demands some work from the reader and helps the reader better understand the pattern. | Patterns make the code better readable and easy to maintain. There are some difficulties <ref name="Difficulties"> http://www.javaworld.com/javaworld/jw-04-2002/jw-0426-designpatterns.html </ref> when design pattern are not used. This reference gives a comprehensive idea on the disadvantages of not using a design pattern and how the code becomes readable and easy after using the strategy pattern. This resource demands some work from the reader and helps the reader better understand the pattern. | ||
=Strategy Pattern | =Strategy Pattern over Switch statements= | ||
This section directs you to an interesting comparison between the Strategy Pattern and Switch statement both of which can be used to dynamically select an algorithm | This section directs you to an interesting comparison between the Strategy Pattern and Switch statement both of which can be used to dynamically select an algorithm <ref name="Difference"> http://blogs.microsoft.co.il/blogs/gilf/archive/2009/11/22/applying-strategy-pattern-instead-of-using-switch-statements.aspx </ref> at run time. This explains the advantages of using the Strategy Pattern over the Switch statement. | ||
=Strategy Pattern | =Strategy Pattern over Inheritance= | ||
[http://docs.doctrine-project.org/en/2.1/cookbook/strategy-cookbook-introduction.html This] is a very good resource that discusses a scenario where Strategy Pattern can be used over Inheritance. It explains the concepts very well and has detailed example in php. | [http://docs.doctrine-project.org/en/2.1/cookbook/strategy-cookbook-introduction.html This] is a very good resource that discusses a scenario where Strategy Pattern can be used over Inheritance. It explains the concepts very well and has detailed example in php. | ||
Line 22: | Line 26: | ||
=Application= | =Application= | ||
[http://static.usenix.org/publications/library/proceedings/coots97/full_papers/garbinato/garbinato.pdf This | Strategy pattern is used in real life appliactions <ref name="Application"> [http://static.usenix.org/publications/library/proceedings/coots97/full_papers/garbinato/garbinato.pdf </ref>. This article explains an interesting applications of the Strategy pattern which is to compose reliable Distributed Protocols. This paper does not contain any code but demonstrates the importance of strategy pattern in real life. | ||
=Short Video Lectures= | |||
To gain further knowledge on the Strategy Pattern there are a number of video lectures that explain the concepts of the pattern. Some of them are mentioned here with a brief description: | |||
* [http://www.youtube.com/watch?v=94t2ayF1l3o This] video is a 9 min short lecture that explains the basic concepts of Strategy Pattern with example given in JAVA | |||
* [http://www.youtube.com/watch?v=-NCgRD9-C6o&feature=related This] 11:30 min video is a very descriptive tutorial which shows how to write code which is descriptive and then write better code using the Strategy Pattern | |||
* [http://www.youtube.com/watch?v=9RBiwpWsJQ4 This] is a 5:50 min video which given an example in PHP | |||
=Conclusion= | |||
The page includes references that describe the usefulness, advantages and comparison of the Strategy pattern with other methodologies. | |||
The reader can get a complete knowledge of the pattern by following the references given. | |||
= See Also = | |||
* [http://en.wikipedia.org/wiki/Strategy_pattern Strategy Pattern] | |||
* [http://www.dofactory.com/Patterns/PatternStrategy.aspx Strategy Pattern and Sorting] | |||
* [http://www.dofactory.com/Patterns/PatternStrategy.aspx Strategy Pattern in c++, c#, Delphi,Java and PHP] | |||
=References= | =References= |
Latest revision as of 20:55, 28 November 2012
Overview
The Internet is the new and the biggest source of information today. The Internet is so overwhelmed with information that sometimes it is difficult to find the exact things. So the purpose of this Wikipedia page is to give the readers a list of references that explain the Strategy pattern and all the details about its implementation and working. The references given in this page will give a complete knowledge of this pattern. Further, with each references given in this page a briefing of what it covers, the programming language used and the purpose that it serves is mentioned.
Strategy Pattern and a Directory of sites
Strategy Pattern[1] is a software design pattern [2] that can be used to select a particular algorithm[3] among many available ones at run time depending on certain conditions. A clear definition of the Strategy Pattern can be found here. This resource gives a general idea of the pattern, a useful reference for readers that have not used this pattern before. The reference is written in a simple and easily understandable way that can be beneficial for a new reader as well as the programmers that want to have a very high level idea about the pattern. It includes a pictorial representation of the fundamental concept behind the pattern and explains it using an example in Java[4]. This resource includes a discussion about the Open/Close principle[5] and relates it with the Strategy pattern.
Strategy Pattern, Getting Started
Now that you know the basic definitions and concept of the Strategy pattern, this will give a deeper insight into the pattern. It explains the motivation behind using the Strategy Pattern and various situations where strategy pattern is useful. A Java example is used to provide better understanding of the concept. Further, it adds some details with regard to implementing a Strategy Pattern such as passing data. It includes a discussion about other patterns that are related to the Strategy pattern.
To gain further insight into the working of the Strategy Pattern, this resource gives a precise description with well accompanied example. The example is in C# [6]and is very descriptive and easy to understand. The author of the article has shown how to apply the Strategy Pattern to solve a real problem. Additionally, it discusses some of the implementation problems associated with this pattern. This is a good extension to the previous resource.
Patterns make the code better readable and easy to maintain. There are some difficulties <ref name="Difficulties"> http://www.javaworld.com/javaworld/jw-04-2002/jw-0426-designpatterns.html </ref> when design pattern are not used. This reference gives a comprehensive idea on the disadvantages of not using a design pattern and how the code becomes readable and easy after using the strategy pattern. This resource demands some work from the reader and helps the reader better understand the pattern.
Strategy Pattern over Switch statements
This section directs you to an interesting comparison between the Strategy Pattern and Switch statement both of which can be used to dynamically select an algorithm <ref name="Difference"> http://blogs.microsoft.co.il/blogs/gilf/archive/2009/11/22/applying-strategy-pattern-instead-of-using-switch-statements.aspx </ref> at run time. This explains the advantages of using the Strategy Pattern over the Switch statement.
Strategy Pattern over Inheritance
This is a very good resource that discusses a scenario where Strategy Pattern can be used over Inheritance. It explains the concepts very well and has detailed example in php.
Application
Strategy pattern is used in real life appliactions <ref name="Application"> [http://static.usenix.org/publications/library/proceedings/coots97/full_papers/garbinato/garbinato.pdf </ref>. This article explains an interesting applications of the Strategy pattern which is to compose reliable Distributed Protocols. This paper does not contain any code but demonstrates the importance of strategy pattern in real life.
Short Video Lectures
To gain further knowledge on the Strategy Pattern there are a number of video lectures that explain the concepts of the pattern. Some of them are mentioned here with a brief description:
- This video is a 9 min short lecture that explains the basic concepts of Strategy Pattern with example given in JAVA
- This 11:30 min video is a very descriptive tutorial which shows how to write code which is descriptive and then write better code using the Strategy Pattern
- This is a 5:50 min video which given an example in PHP
Conclusion
The page includes references that describe the usefulness, advantages and comparison of the Strategy pattern with other methodologies. The reader can get a complete knowledge of the pattern by following the references given.
See Also
References
<references />