Strategy Pattern vs Dependency Injection
问题 How is strategy pattern is different then dependency injection? ie below is what you can do with Strategy pattern: class Foo{ private readonly ISortAlgo _sortAlgo; public Foo(ISortAlgo sortAlgo) { _sortAlgo = sortAlgo; } public void Sort() { _sortAlgo.sort(); } } with DI you can do the same, essentially you can have constructor, setter, interface etc. injection. and it would give the same effect as Strategy pattern. I am aware that DI is also set of other principles, such as loose coupling,