Giter Site home page Giter Site logo

bzdgn / gang-of-four-design-patterns-in-java Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 4.0 34 KB

Implementation Examples And Notes on Gang Of Four Design Patterns

Java 100.00%
gang-of-four design-patterns java gof creational-patterns structural-patterns behavioral-patterns creational structural behavioral

gang-of-four-design-patterns-in-java's Introduction

Gang Of Four Design Patterns In Java


I'm uploading this project to git in order to self learning and recap my design patterns knowledge. Design patterns are needed to make good practice and generalized design solutions for the known programming design problems. This project is about famous Gang Of Four Design Patterns and their implementation examples in Java.


Creational Design Patterns

Structural Design Patterns

Behavioral Design Patterns


Design Patterns Notes

A - Creational Design Patterns

    1. Singleton

         Intro

         Singleton guarantees only one instance of the class is going to be created. It guarantees the control of a resource. Singleton is a creational design pattern thus the instantiation of the class is controlled by the implementation of this pattern. It is usually lazily loaded. Singleton is responsible for creating itself and managing its own lifecycle. It is static in nature but it is not implemented using a static class typically. Because in order to make the implementation thread-safe, it is not build-up with static class. The constructor of the singleton is private so that other than the class itself, no other class can call the constructor of the Singleton class. And the reference to the class instance, which can only be only unique per runtime environment, is also stored as private so that only the class itself can reach and control its lifecycle. Also notify that there are no parameters in the private constructor and if there should be, it violates the rules of Singleton. If you require parameters to create an instance of a class, you should prefer or you need a factory pattern.

         Examples

         Java Runtime Environment, Logger, Spring Beans(they are Singleton's by default), Graphics Managers

         Pros and Cons

         xxxxxxxxxxxx

         Dummy

         xxxxxxxxxxxx

    2. Builder

    3. Prototype

    4. Factory

    5. Abstract Factory

gang-of-four-design-patterns-in-java's People

Contributors

bzdgn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.