Design patterns in Core Java are well-established solutions to common problems that developers encounter during software development. These patterns represent best practices used by experienced object-oriented software developers. They’re categorized into three main groups: Creational, Structural, and Behavioral patterns. Here’s a brief overview of each category with examples:

Creational Patterns

These patterns are all about class instantiation or object creation. They can be divided into class-creation patterns and object-creational patterns.

  1. Singleton Pattern: Ensures a class has only one instance and provides a global point of access to that instance.
  2. Factory Method Pattern: Defines an interface for creating an object, but lets subclasses alter the type of objects that will be created.
  3. Abstract Factory Pattern: Provides an interface for creating families of related or dependent objects without specifying their concrete classes.
  4. Builder Pattern: Allows for the step-by-step construction of a complex object so that the same construction process can create different representations.
  5. Prototype Pattern: Creates new objects by copying an existing object, known as a prototype.

Structural Patterns

These patterns are concerned with how classes and objects are composed to form larger structures.

  1. Adapter Pattern: Allows objects with incompatible interfaces to collaborate.
  2. Composite Pattern: Composes objects into tree structures to represent part-whole hierarchies. It allows clients to treat individual objects and compositions of objects uniformly.
  3. Proxy Pattern: Provides a surrogate or placeholder for another object to control access to it.
  4. Flyweight Pattern: Minimizes memory usage or computational expenses by sharing as much as possible with similar objects.
  5. Bridge Pattern: Decouples an abstraction from its implementation so that the two can vary independently.

Behavioral Patterns

These patterns are all about class’s objects communication. Behavioral patterns are concerned with algorithms and the assignment of responsibilities between objects.

  1. Observer Pattern: Defines a dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
  2. Strategy Pattern: Defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.
  3. Command Pattern: Turns a request into a stand-alone object that contains all information about the request. This transformation allows you to parameterize methods with different requests, delay or queue a request’s execution, and support undoable operations.
  4. State Pattern: Allows an object to alter its behavior when its internal state changes. The object will appear to change its class.
  5. Template Method Pattern: Defines the skeleton of an algorithm in the superclass but lets subclasses override specific steps of the algorithm without changing its structure.