Look for forces first
Conditional creation, swappable policies, state-driven behavior, and wrapper layering are better clues than names.
Real code rarely arrives with neat textbook labels. Patterns are often partial, adapted, or blended with framework conventions. The skill is not pattern trivia. The skill is recognizing the structural and behavioral cues that indicate a design is solving a familiar problem in a familiar way.
Java teams often work in frameworks and legacy codebases where patterns are present but not explicitly named. Learning to spot them improves code reading, refactoring, and architecture discussions without forcing every design into a catalog label.
Spotting patterns in real code starts with reading the force the code is responding to. If behavior varies cleanly behind one interface, Strategy may be present. If object creation has been localized and delegated, Factory Method may be in play. If wrappers preserve the same interface while layering behavior, Decorator may be the right lens.
For Java developers, this skill matters because most codebases are not written as teaching examples. Patterns show up as practical adaptations shaped by frameworks, domain constraints, and team conventions.
The point is not to prove that a pattern is “really there.” The point is to improve your reading of the design so you can modify it more safely.
Conditional creation, swappable policies, state-driven behavior, and wrapper layering are better clues than names.
A Spring bean factory or strategy registry may embody familiar pattern ideas without textbook packaging.
A codebase may show a strong Strategy or Builder direction without implementing every classic role exactly.
package org.javaomnibus.ecommerce.gof;
public interface DiscountPolicy {
Money apply(Order order, Money subtotal);
}
public final class LoyaltyDiscountPolicy implements DiscountPolicy {
@Override
public Money apply(Order order, Money subtotal) {
return subtotal.multiply(95).divide(100);
}
}
public final class CheckoutPricingService {
private final DiscountPolicy discountPolicy;
public CheckoutPricingService(DiscountPolicy discountPolicy) {
this.discountPolicy = discountPolicy;
}
public Money finalTotal(Order order) {
return discountPolicy.apply(order, order.total());
}
}
Pattern recognition can become confirmation bias if you force a label too early. It is better to say a design is strategy-like or builder-like when the structure is partial or hybrid.