This blog post demonstrates another approach on how to implement the strategy pattern with dependency injection. As for my DI framework, I choose the Spring Framework:
![](https://upload.wikimedia.org/wikipedia/commons/4/45/W3sDesign_Strategy_Design_Pattern_UML.jpg)
Firstly, let's have a look at how the Strategy Pattern is implemented in a classic way. As a starting point, we have a HeroController
that should add a hero in HeroRepository
depends on which repository was chosen by the user.