Python版 https://github.com/faif/python-patterns/blob/master/creational/borg.py #!/usr/bin/env python # -*- coding: utf-8 -*- """ *What is this pattern about? The Borg pattern (also known as the Monostate pattern) is a way to implement singl…
Python版 https://github.com/faif/python-patterns/blob/master/creational/factory_method.py #!/usr/bin/env python # -*- coding: utf-8 -*- """*What is this pattern about? >>这个设计模式是干什么的 The Factory Method pattern can be used to create an i…
Python版 https://github.com/faif/python-patterns/blob/master/creational/pool.py #!/usr/bin/env python # -*- coding: utf-8 -*- """ *What is this pattern about? This pattern is used when creating an object is costly (and they are created frequ…
Python版 https://github.com/faif/python-patterns/blob/master/creational/abstract_factory.py #!/usr/bin/env python # -*- coding: utf-8 -*- """ *What is this pattern about? In Java and other languages, the Abstract Factory Pattern serves to pr…
Python版 https://github.com/faif/python-patterns/blob/master/creational/builder.py #!/usr/bin/python # -*- coding : utf-8 -*- """ *What is this pattern about? It decouples the creation of a complex object and its representation, so that the…
package com.tn.pattern; public class Client { public static void main(String[] args) { Director director=Director.getInstance(); director.construct(new ConcreteBuilder1()); director.construct(new ConcreteBuilder2()); } } class Director{ static Direct…