Tagged “Creational”
7 articles with this tag.
- Abstract FactoryCreate families of related objects that must be used together, without naming their concrete classes. A runnable Java 21 example builds SQL for PostgreSQL and MySQL from one client, plus how Abstract Factory differs from Factory Method, trade-offs and interview questions.
- GoF OverviewA map of the 23 Gang of Four design patterns: the three categories, class versus object scope, one-line intents, JDK examples, and how to choose between patterns that look alike.
- BuilderConstruct complex objects step by step. Covers both the GoF Builder (director plus interchangeable builders) and the fluent Effective Java builder for immutable objects, with runnable Java 21 examples.
- Factory MethodLet subclasses decide which class to instantiate. A runnable Java 21 report-export example, a clear distinction from the 'simple factory' and static factory methods, UML, trade-offs and interview questions.
- Factory Patterns ComparedSimple factory, static factory method, GoF Factory Method, Abstract Factory and Builder — what each one is, how they differ, and which to choose.
- PrototypeCreate new objects by copying a configured prototype instead of building them from scratch. Copy constructors versus Cloneable, shallow versus deep copies, a prototype registry, and a runnable Java 21 example that shows the shallow-copy bug.
- SingletonEnsure a class has one instance and a global access point — and why that is harder, and more harmful, than it looks. Enum singletons, the holder idiom, double-checked locking with volatile, testability problems and the dependency-injection alternative, with a runnable Java 21 example.