Posts

Showing posts from February, 2018

Examples of GoF Design Patterns in Java's core libraries

I listed out some good examples of these Design Patterns in Java's core libraries. Creational patterns Creational patterns involve object instantiation and all provide a way to decouple a client from the objects it needs to instantiate. This pattern can be further divided into class-creation patterns and object-creational patterns. While class-creation patterns use inheritance effectively in the instantiation process, object-creation patterns use delegation effectively to get the job done. Abstract factory Provide an interface for creating families of related or dependent objects without specifying their concrete classes. javax.xml.parsers.DocumentBuilderFactory#newInstance() javax.xml.transform.TransformerFactory#newInstance() javax.xml.xpath.XPathFactory#newInstance() Builder Separate the construction of a complex object from its representation so that the same construction process can create different representations. java.lang.StringBuilder#append()  (unsynchronized) java.lang.