Why does it seem to me that using Strategy is just putting off the if/else to the Factory? 开发者_如何转开发Using Strategy, doesn't a Factory need to figure out which concrete class to instantiate, and doesn't it do so by if/else?
Is another option to use a Map/List somehow, and have the keys be a name of the class to instantiate, and maybe have the class using the Factory pass in a name?
Map\List is an implemetation of Factory pattern.
Using Strategy patter is better than if\else because it's creates les coupled code. With Factory+Startegy you can extend algorithms of processing without touch of client code, and have more ways to configure code dynamicaly (withot recompile).
精彩评论