Java Omnibus
OOAD & Architecture / GoF patterns / GoF Patterns Cheatsheet for Java
GoF Patterns Java Order Management
GoF Patterns

A patterns cheatsheet is useful when you need a quick force-to-pattern map, not when you need depth.

This cheatsheet is designed as a compact decision aid. It is not a substitute for the detailed pages. Its job is to help you map a recurring design force to a likely pattern family and then route you toward the right page for deeper judgment.

Why This Topic Matters

Why it matters in real Java systems

Java teams often need a lightweight reference during design or code review. A concise cheatsheet helps keep pattern discussions grounded without forcing the team into long catalog digressions.

Core Explanation

The design lens behind this page

A good cheatsheet should shorten orientation time without pretending that judgment can be reduced to one line. That is why this page groups patterns by category, highlights the core force each one addresses, and points toward nearby alternatives that are easy to confuse.

For Java developers, this is useful in architecture reviews, team design sessions, and refactoring work where you need a shared starting point before discussing specifics.

Use the cheatsheet to get oriented, then move into the detailed page when the choice starts to matter concretely.

Concept Breakdown

Key ideas to hold onto

Concept

Fast lookup

Use it when you need a quick reminder of what each family is trying to solve.

Concept

Best for comparison

It is especially useful when several patterns sound similar on the surface.

Concept

Depth still matters

Cheatsheets help you orient quickly, then deeper pages help you choose responsibly.

Java Example

Java example in the Order Management domain

Java example: three small forces, three different likely pattern directions
package org.javaomnibus.ecommerce.gof;

public final class PatternPressureExamples {
    PaymentGateway gatewayFor(String paymentMethod) { return null; }
    Money discountFor(Order order) { return null; }
    ShipmentWorkflow workflowFor(Order order) { return null; }
}
Code Walkthrough

Step by step

  1. Gateway selection often points toward Factory Method or Abstract Factory.
  2. Discount variation often points toward Strategy.
  3. Workflow or lifecycle variation may point toward State or Command depending on the pressure.
  4. This is the level of speed a cheatsheet is designed to support.
Real-World Usage

Where this helps in practice

  • Code reviews
  • Team design discussions
  • Quick pattern refreshers before deeper implementation choices
Quick Map

Quick Map

Pattern Family Best-fit force Easy confusion
Factory MethodCreationalConditional creation of one product familyAbstract Factory, Builder
Abstract FactoryCreationalCreating matching product families togetherFactory Method, Builder
BuilderCreationalMulti-step construction with readable assemblyFactory Method, Prototype
PrototypeCreationalCloning configured objectsBuilder, Flyweight
StrategyBehavioralSwappable algorithm or policy variationState, Command
StateBehavioralBehavior changing by lifecycle stateStrategy, Command
AdapterStructuralInterface mismatchFacade, Proxy
DecoratorStructuralOptional layered behaviorProxy, Composite
Trade-Offs

When to be careful

Cheatsheets can oversimplify. They are most useful when they help you narrow the field, not when they are treated as the final decision.

Common Mistakes

Frequent mistakes to watch for

  • Using the cheatsheet instead of reading the detailed page for a consequential design choice
  • Assuming a one-line summary captures all pattern trade-offs
  • Ignoring context because the cheatsheet label seemed to match quickly
  • Treating the cheatsheet as a substitute for code-level reasoning
Related Pages

Related concepts


What To Read Next