C# Strategy Design Pattern by Delegate vs OOP

后端 未结 5 1401
悲哀的现实
悲哀的现实 2020-12-23 15:07

I wonder what\'s the pros/cons of using delegate vs OOP when implementing strategy design pattern?

Which one do you recommend to use? or what kind of problem does de

5条回答
  •  难免孤独
    2020-12-23 15:10

    I like to use an interface to abstract my strategy. My concrete implementations then have a visible file for each strategy. When working with a Class instead of a method it gives you more flexibility. I can use Rhino mocks to mock out the strategy to test around it. I can also easy use DI frameworks such as Ninject to bind the strategy application wide very easily. I use Delegates to extract the implementation mostly in WinForm Dialogs.

提交回复
热议问题