Design Pattern: Strategy Pattern in Java

Strategy Pattern

Strategy pattern is used when there are multiple algorithms available for the same purpose, and we need to decide between those algorithms. Strategy pattern helps to decide the algorithm and return the generated object to be used. This article demonstrates Strategy pattern implementations in Java. Check the following examples.

Design Pattern: Composite Pattern in Java

Composite pattern is used to handle the operation of a bunch of classes (having the same interface), to operate the same function of all items a the same time. Using Composite pattern the client can ignore the difference between the Composition and Leaf classes, and can use the composition considering the same interface. This article demonstrates Composite pattern implementations in Java. Check the following examples.