Design Pattern: Command Pattern
Command pattern wraps a request/command in an object. Then we can pass the object anywhere and later when we want to execute the command the object can be used.
Command pattern wraps a request/command in an object. Then we can pass the object anywhere and later when we want to execute the command the object can be used.
Chain of Responsibility pattern is used to decouple the request and response handling. Multiple objects create a chain that is used to handle a request. This article demonstrates Chain of Responsibility pattern implementations in Java. Check the following examples.
Chain of Responsibility pattern forms a chain of objects that is responsible for handling a command/operation request. As the responsibility is distributed into one or more objects and a single object is not responsible for handling a request, so that ensures the decoupling of the request sender and processor. The request is sent to the chain of objects without specifying the handler. Which object will handle the request is not predefined, that is decided on-the-fly while processing.
Prototype pattern defines the process of cloning an existing object and creating a new object from that. When we want to simplify the creation process of an object and optimize the performance of object creation, we can clone an existing object and create a new one from that.
Builder pattern is used to hide the complexity of building complex objects from the client and also this pattern is responsible for building objects step-by-step. This article demonstrates Builder pattern implementations in Java.
When we need to construct a complex object, then Builder Pattern comes into play. Builder Pattern will hide the complexity of the object construction from the user. Builder Pattern will allow the complex object to be built step-by-step.
Abstract Factory pattern is used to generate multiple factory generators. This article demonstrates Abstract Factory pattern implementations in Java.
Bridge pattern is used to decouple implementation and abstraction. This article demonstrates Bridge pattern implementations in Java.
Using Bridge we can decouple the implementation of UI Element and Color Schema, so the elements and colors will have a separate hierarchy. That way the implementation of the Elements and Color will be independent and the element color can be set dynamically.
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.