Sample source code for different programming patterns in Java.
Most, if not all, code and documentation was found on the web at the following locations:
https://www.journaldev.com/1827/java-design-patterns-example-tutorial#abstract-factory-pattern https://springframework.guru/gang-of-four-design-patterns/
Additionally, information and sample code came from Pluralsight (https://www.pluralsight.com). Specifically from the "Design Patterns in Java: Creational", "Design Patterns in Java: Structural" and "Design Patterns in Java: Behavioral" sections.
Creational Patterns: These patterns provide solutions to instantiate an object in the best possible way for specific solutions.
- Singleton
- Factory: Abstracts the way objects are created.
- Abstract Factory: Abstract factory abstracts how the factories are created. (aka “factory of factories“.)
- Builder
- Prototype
Structural Design Patterns: Provides different ways to create a class structure. For example, using inheritance and composition to create a large object from small objects.
This pattern is widely used in the JDK, Spring and Struts.
- Adapter
- Composite
- Proxy
- Flyweight
- Facade
- Bridge
- Decorator
Behavioral Design Patterns: Provide solutions for better interaction between objects and how to provide loose coupling and flexibility to extend easily.
- Template Method
- Mediator
- Chain of Responsibility
- Observer
- Strategy
- Command
- State
- Visitor
- Interpreter
- Iterator
- Memento