Category: Java design patterns
-
Abstract Factory Design Pattern in Java
1. Introduction It provides an interface for creating families of related or dependent objects without specifying their concrete classes. An abstract factory is essentially a factory of factories. This design pattern encapsulates a collection of related factories that share a common theme. Instead of instantiating individual product classes directly, you create a specific concrete factory,…
-
Factory Method Pattern
1. Introduction It defines an interface for creating an object, but lets subclasses decide which class to instantiate. The Factory Method pattern lets a class defer instantiation to subclasses. Key Features: You begin with an abstract creator class, commonly referred to as the creator, which establishes the fundamental framework of the application. The subclasses that…
-
Proxy design pattern – Java
1. Introduction Proxy means “power or authority that is given to allow an entity to act for someone else”. Proxy objects are used as surrogates and handlers for original objects. The objective of a proxy object is to control the creation of and access to the real object it represents. A common use of a…
-
Observer Pattern – Java
1. Introduction According to GoF definition, Observer pattern defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.Observer pattern is a behavioral design pattern. In this design pattern there is a subject to which observers subscribe. Whenever the state of subject changes, all its…
-
Simple Factory Pattern – Java
1. Introduction In this tutorial, we’ll discuss Factory Method Pattern. This design pattern comes under creational design pattern as this pattern is used to create objects. In this pattern, we hide the creation logic from the client. We only provide a uniform interface for creating objects.In this design pattern we define an interface for creating…
