Design Pattern

Strategy pattern:
Motivation :
There are common situations when classes differ only in their behavior. For this case is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime.
Intent :
Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from client that use it.
Implementation in GO :
Extract common behavior from algorithms and put them into an interface. For each different algorithm to implement the interface.

本篇發表於 Uncategorized。將永久鏈結加入書籤。


在下方填入你的資料或按右方圖示以社群網站登入: Logo

您的留言將使用 帳號。 登出 / 變更 )

Twitter picture

您的留言將使用 Twitter 帳號。 登出 / 變更 )


您的留言將使用 Facebook 帳號。 登出 / 變更 )

Google+ photo

您的留言將使用 Google+ 帳號。 登出 / 變更 )

連結到 %s