Strategy Pattern in Swift
If we have a task that has multiple different implementations and we might need to use all or some of them during runtime, we can get help from strategy pattern. It is called strategy because according to our strategy, we might use any implementation that fulfills the task.
I will provide an example:
Here, we have a SortAlgorithm protocol and there are two different implementations named MergeSort and QuickSort. SortingManager class initialized with SortAlgorithm and we can change the algorithm on the fly with update function of SortingManager class.