Coder Social home page Coder Social logo

design-pattern-revised-2023's Introduction

gof-impl-java

Discovering the design patterns in GOF way

This repo contains my personal notes and practice based on my understanding of the design patterns discussed in GOF book.

Criteria (Scope)

  • Class (The pattern primarily applies to classes,relationship between classes and subclasses, established through inheritance, static, fixed at compile time)
  • Object(The pattern primarily applies to objects, dynamic, can be changed at runtime)

Criteria (Prupose)

  • Creational : Concerns the process of object creation.Creational class design patterns defer some part of the object creation to subclasses while creation object patterns defer it to another object.
  • Structural : Deals with the composition of classes and objects. The structural class patterns use inheritance to compose classes while structural object patterns describe ways to assemble objects.
  • Behavioral : Characterizes the way classes or objects interact and distribute responsibility.The behavioral class patterns use inheritance to describe algorithms and flow of control while behavioral object patterns describe how a group of objects co-operate to perform a task that no single object can carry out alone.

Note

  • Creational patterns deal with object creation. Creational design patterns defer some part of the object creation to subclasses while creation object patterns defer it to another object.
  • Structural pattern deals with the composition of classes or objects. The structural class patterns use inheritance to compose classes while structural object patterns describe ways to assemble objects.
  • Behavioral patterns characterize the ways in which classes or objects interact and distribute responsibility.The behavioral class patterns use inheritance to describe algorithms and flow of control while behavioral object patterns describe how a group of objects co-operate to perform a task that no single object can carry our alone.

Creational Patterns:

Simple Factory(Static) vs Factory Method vs Abstract Factory

Simple Factory(Static)

Factory Method (Scope - Class)

Abstract factory (Scope - Object)

Prototype

  • Let's assume you have an object which is very expensive to create(The cached result of an AI model, A object with a tcp connection and some metadata, an object containing the response of a REST API etc) and the software requires a new instance of the object. In this scenario, we can use prototype design pattern which demonstrates how to create a copy of an existing object. It can be shallow copy or deep copy depending on the use case and can be tackled at implementation level. Java Object.clone() method and Cloneable interface is an example.

Builder

It separates the construction of a complex object from its representation so that the same construction processes can create different representations. - GOF

design-pattern-revised-2023's People

Contributors

mdnajimahmed avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.