Giter VIP home page Giter VIP logo

java-patterns-implementations's Introduction

java-patterns-implementations

Personal implementations in java of several patterns with usage example ready to use.


Database

DAO & DTO

Data Access Object & Data Transfer Object. DAO - Design pattern, used to encapsulate the access to a persistence resource (e.g a database) and eliminate dependencies which come with the implementation of the code. DTO is the object which representates an entity of the database, with all its own properties to be manipulated.


Structural

Façade

Helps with MVC. Establishes a new layer to separate and encapsulate the code between view & controller.

Singleton

Limits and sets a way to access an unique object instantiation during the whole execution of a program.


Behavioural

State

Allows to change the behaviour of an object through its own state. Depending the state the object is at, allows to manipulate it one way or another. Parts:

  • Context - It contains the action which will change depending on the current state. When called this action, it will delegate into the State object saved.
  • State Interface - Contains the design of the action. The context will save this raw.
  • Concrete States - Each one extends the interface and will override the action & its results.

Memento

Allows to restore an object to a previous state. It makes snapshots of the object and saves them, allowing later to restore any of them. Behaviour pattern. It does save snapshots of a class, to be able to recover a previous state of an object. Parts:

  • Originator - Class from which we save its states. e.g. a DTO.
  • Memento - It's a Snapshot which saves the content of the Originator in a punctual state.
  • Caretaker - Class where we do save the several Mementos. From it we do save or load Mementos.

Creational

Builder

Allows to create beans easily (and fluently) for cases where we have lots of parameters (+4-5), with some of them required and others optional.

Factory

Uses factory methods to add an abstraction layout. Allows for example to be able to connect to several databases doing the swap by just changing two parameters in a config file.


Patterns to take a look into

flyweight
service provider framework
bridge
adapter
template method

java-patterns-implementations's People

Contributors

mariocodes avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

alexrogalskiy

java-patterns-implementations's Issues

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.