10 Software Design Patterns used in Java Core Libraries
Essential Design Patterns that are used in JDK
21 famous software design patterns that are summarised and presented by GoF can be found frequently in Java Core Libraries. Depending on situation different patterns are elegant way to implement object oriented programming. Let us have a quick overview to 10 design patterns that are applied in different parts of Java Development Kit.
Creational Design Patterns — this patterns deal with different techniques of object instantiation.
Factory — this design pattern aims to collect instantiation of classes in a single centralised Factory class in order to have a full control over objects. Please see my other article for more information about this pattern. Examples are:
- java.util.Collections — singletonList(), singletonMap()
- java.util.ResourceBundle — getBundle()
Abstract Factory — this is a factory design pattern with extra level of abstraction. Examples are:
- javax.xml.parsers.DocumentBuilderFactory — newInstance()
- javax.xml.transform.TransformerFactory — newInstance()
- javax.xml.xpath.XPathFactory — newInstance()
Builder — this pattern helps us to construct complex objects with the help of simpler interfaces. Examples are:
Singleton — this pattern is one of the most used patterns and its goal is to prevent instantiating the same class multiple times allowing only single instance across the given context. Please see my other article for more information about this pattern. Examples are:
Structural Design Patterns — this kind of design patterns cope with structural composition of software components to simplify the complex objects using mostly inheritance.
Adapter — this design patterns, as name suggests, is a converter pattern that connects incompatible interfaces. Examples are:
- java.util.Arrays — asList()
- java.util.Collections — list(), enumeration()
- java.io.InputStreamReader
Facade — this design pattern is basically adding another interface to simplify complex interfaces. Examples are:
- Faces Api — HttpServletRequest, HttpServletResponse
Proxy — this pattern uses proxies to add substitution to complex objects. Please see my other article for more information about this pattern. Examples are:
- java.lang.reflect.Proxy — all methods are proxies out of box
Behavioural Design Patterns — this design patterns deal with the way how the different objects interact with each other.
Observer — this pattern is making communication between subject and object to let them know that changes are happened. Examples are:
Strategy — this design pattern allows us using different strategies by writing generic code. Examples are:
- java.util.Comparator
- javax.servlet.Filter — doFilter()
Template — this design pattern provides flexibility to objects by abstracting several sub-parts and letting extenders to implement it. Please see my other article for more information about this pattern. Examples are:






