Strategy Pattern

1,179 views
1,061 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,179
On SlideShare
0
From Embeds
0
Number of Embeds
8
Actions
Shares
0
Downloads
25
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Strategy Pattern

  1. 1. Strategy Pattern<br />Albert Guo<br />junyuo@gmail.com<br />
  2. 2. Motivation<br />Intent<br />Implementation<br />Applicability & Examples<br />2<br />Agenda<br />
  3. 3. There are common situations when classes differ only in their behavior. For this cases is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. <br />Motivation<br />3<br />
  4. 4. Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.<br />4<br />Intent<br />
  5. 5. 5<br />Implementation<br />
  6. 6. 6<br />Implementation – cont.<br />
  7. 7. Applicability & Examples<br />7<br />
  8. 8. 8<br />Applicability & Examples – cont.<br />
  9. 9. 9<br />Applicability & Examples – cont.<br />
  10. 10. 10<br />Applicability & Examples – cont.<br />

×