Properties: - Separates implementation from algorithm (strategy). - The same class can be used with different algorithms. Implementation: - Strategy creates an abstraction for different algorithms. - ConcreteStrategy implements strategy interface for a specific algorithm. - Context object uses strategy object to do its job. Its behaviour depends on the concrete strategy implementation. Java Standard Library Implementations: - java.util.Collections.html#sort(java.util.List, java.util.Comparator) uses Comparator as strategy. Example Usage: ...
Software Engineering experiences and best practices