I'm kind of a beginner when it comes to design patterns. Any thoughts on implementing the strategy pattern/ like this:
public class SomeClass { private Strategy strategy = new DefaultStrategy(); public void provideCustomStrategy(Strategy strategy) { this.strategy = strategy; } }
This will ensure loose coupling and all the other benefits of the Strategy Pattern and DI. At the same time you don't force the user to provide a strategy, and the user can decide to provide a custom strategy for corner cases, etc. One can achieve the same goal with constructor-injection if you provide a constructor with a Strategy-parameter. I think this implementation will provide maximum flexibility in many cases.