/DesignPatterns

Implementation of Design Patterns in Go and Java

Primary LanguageGo

Design Patterns in Go and Java

Creational Design Pattern

  1. Factory Design Pattern
    Example UML for Factory Pattern:
    factory_design_pattern

  2. Abstract Factory Design Pattern
    Example UML for Abstract Factory Pattern:
    abstract_factory_design_pattern

  3. Singleton Design Pattern

    • Use this pattern when there must be exactly one instance of a class, and it must be accessible globally.
    • When the sole instance should be extensible by subclassing it.
      Example UML for Singleton Design Pattern:
      singleton_design_pattern
  4. Builder Design Pattern

  5. Prototype Design Pattern

  6. Object Pool Design Pattern

    • Use this pattern when the cost of object creation is high and the number of objects required at a time are low.
    • For example, the database connection object.
      Example UML for Object Pool Design Pattern:
      object_pool_design_pattern

Structural Design Patterns

  1. Adapter Design Pattern

    • Convert the interface of a class into another interface clients expect.
    • Adapter lets classes work together that couldn't otherwise because of incompatible interfaces. Example UML for Adapter Pattern:
      adapter_design_pattern
  2. Decorator Design Pattern

    • Use this pattern to attach additional responsibilities to an individual objects dynamically and transparently, that is, without affecting other objects.
    • Use for responsibilities that can be withdrawn.
    • Use when extension by subclassing is impossible. decorator_design_pattern

Behavioural Design Patterns

  1. Strategy Design Pattern
    Example UML for Strategy Pattern:
    strategy_design_pattern

Domain Driven Design Patterns

  1. Repository Design Pattern
    Repository design pattern is used for providing abstraction to the data access logic. Using Repository Design Pattern, the business logic layer of your application need not have any knowledge on how data persistence happens beneath.
    Example UML for Repository Pattern:
    repository_design_pattern