Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

This repository contains all the design patterns with example.

NotificationsYou must be signed in to change notification settings

javamultiplex/java-design-pattern

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

92 Commits
 
 
 
 
 
 
 
 

Repository files navigation

  1. Creational
    • Prototype - A fully initialized instance to be copied or cloned.Ex - Chess board.
    • Builder - Seperate object construction from its representation.Ex - Menu of any restaurant
    • Singleton - A class of which only a single instance can exist.Ex - President of country, Database connection, Logging
    • Factory method - Creates a factory of object types.Ex - Shape factory that generates different shapes.
  2. Structural
    • Proxy - An object representing another object.Ex - Credit card, Debit card
    • Decorator - Add responsibilities to the object dynamically.Ex - Adding discount on order, Adding toppings on pizza, Java IO.
    • Facade - A single class that represent an entire subsystem.Ex - Event manager, Online booking order.
    • Adapter - Match interfaces of different class.Ex - Power adapter.
    • Flyweight - A fine grained instance used for efficient sharing.Ex - Public switched network, JDBC Connection pooling.
  3. Behavioural
    • Chain of resposibility - A way of passing a request between chain of objects.Ex - Exception handling in Java.
    • Iterator - Sequentially access elements of a collection.Ex - Iterator class, next and prev button on Tv remote.
    • State - Alter an object behaviour when its state changes.Ex - Fan wall control
    • Strategy - Encapsulate an algorithm inside a class.Ex - Sorting based on different algorithms.
    • Observer - A way of notifying a change to number of classes.Ex - Newspaper
    • Visitor - Define a new operation to a class without change.Ex - Operation of a taxi company.
    • Template method - Defer an exact steps of an algorithm to a sub class.Ex - House plan.
    • Command - Encapsulate a command request as a object.Ex - Runnable interface, Waiter take order and pass it to cook.
    • Memento - Capture and restore object's internal state.Ex - Serialization, Undo/Redo.
    • Mediator - Defines simplified communication between classes.Ex - Air traffic controller.

[8]ページ先頭

©2009-2025 Movatter.jp