Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint

11.6. Summary

After examining some applications using the Strategy design pattern, you can see the scope of possibilities for it as a design pattern. It's certainly a showcase for good OOP practices. Perhaps most obvious is how it uses composition instead of inheritance to develop and use the algorithms. However, it still uses the basic OOP feature of inheritance in its concrete context classes.

Furthermore, you can clearly see polymorphism in the variety of ways the different strategies are implemented. Each of the interfaces demonstrates abstraction along with the main context class. All the strategies encapsulate an algorithm, and each serves as a delegate to another class. So there you have it, the four basic elements of good OOP:

  • Inheritance

  • Polymorphism

  • Abstraction

  • Encapsulation


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint