Skip to content

oldsui/DesignPatternTutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Design Pattern Tutorial

1. Iterator

concrete iterator -- implements --> iterator <-- has -- aggregate <-- implements -- concrete aggregate

concrete iterator -- has --> concrete aggregate

2. Adapter

Adaptee <-- extends -- Adapter -- implements --> Target(interface),  used by client 

3. Template

Abstract SuperClass: abstract method1, abstract method2, do() {method1(), method2()}

ChildClass: method1, method2

SuperClass child = new ChildClass(...)  // Liskov Substitution Principle: LSP

4. Factory

Framework(Abstract classes):
    Factory                             Product
        createProduct()


Concrete classes:
    MyFactory                           MyProduct

5. Singleton

public class Singleton {
    private static Singleton myInstance;
    private Singleton() {
    }
    public static Singleton getInstance() {
        if (myInstance == null) {
            myInstance = new Singleton();
        }
        return myInstance;
    }
}

6. Prototype

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages