Skip to content

jl681/design-patterns

Repository files navigation

Learning record of java design patterns

Builder Pattern

Factory

Simple Factory

Here we simply move the instantiation logic to a separate class and most commonly to a static method to this class. Some do not consider Simple Factory to be a 'design pattern', as it's simply a method that encapsulates object instantiation. Nothing complex goes on in the method. We are studying Simple Factory as it is often confused with "Factory Method" pattern.

java.text.NumberFormat.getInstance is an example of Simple Factory

simple-factory uml diagram

Factory Method

a real example of Factory Method is java.util.Collection.iterator() method factory-method_uml_diagram

Abstract Factory

abstarct-factory uml diagram

Abstract Factory makes use of factory method pattern. You can think of abstract factory as an object with multiple factory methods.

Singleton

Eager Singleton / Lazy Singleton / Enum Singleton java.lang.Runtime is a singleton In eager singleton implementation the singleton instance is created as soon the singleton class is referenced.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages