Singleton Design Pattern

  Most of the times we need to create single instance of a class for ex. creating a single database connection, creating a single instance for logging or caching purpose. But how to create a single instance of a class in java ? Java provides Singleton Design Pattern to create only one instance of a class. Let’s learn in detail about this pattern. Singleton Design Pattern is a creational design pattern. Singleton pattern is one of the simplest design patterns. This pattern restricts the instantiation of a class to one object.…

Read More

What are Design Patterns ?

  Design Patterns are solutions to the recurring problems in Software Design. These patterns are proven solutions to specific problems. Patterns helps to speed up the development process by providing tested, proven approaches. Patterns make it easier to reuse successful designs and architectures. Advantages of Using Design Patterns: Code reusability and extensibility Use of patterns in Applications makes development faster.   Gang of Four Design Patterns: What is Gang of Four ? Gang of Four (Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides) are the authors of the book “Design…

Read More

Abstract Factory Pattern

  What is Abstract Factory Pattern ? Abstract Factory Pattern is a creational design pattern. This pattern creates a super factory which in turn creates other factories. Abstract Factory pattern provides an interface for creating families of related or dependent objects without specifying their concrete classes. This pattern provides with a way to encapsulate concrete factories that share some similarity with each other, meaning they implement same interface or abstract class. When to use Abstract Factory Pattern ? When you want to defer the decision about which factory to use…

Read More

Factory Design Pattern

  What is Factory Design Pattern ? Factory Design Pattern is a creational design pattern. This pattern says that define an interface or abstract class for creating an object but let the sub-classes decide which class to instantiate which means that sub-classes are responsible for creating an instance of the class. When to use Factory Design Pattern ? When a class cannot anticipate the type of objects it needs to create beforehand. When a class requires its sub-classes to specify the type of objects that it creates. Most suitable where there…

Read More