Design product and creator hierarchies that stay extensible without becoming inheritance-heavy or brittle.
Product hierarchy: The set of related types a factory method may create, usually unified by an interface or abstract base type.
Factory Method usually introduces two parallel ideas: a product side and a creator side. That can be useful, but it can also become brittle if every new variant forces a growing inheritance tree on both sides.
The product interface should represent the behavior the client actually needs, not every method the concrete classes happen to expose.
1interface NotificationSender {
2 void send(String recipient, String message);
3}
If the contract is small and stable, new products are cheaper to add and easier to test.
A creator hierarchy only earns its complexity when the base class does meaningful work around the creation point:
If the base class does almost nothing except declare the factory method, inheritance may be doing too much work for too little payoff.
Good Java factory-method designs usually depend on:
Bad designs often leak concrete product details back into the caller, which defeats the point of the hierarchy.
The first mistake is growing mirrored hierarchies mechanically: every new product forces a new creator subclass even when the creator adds no real behavior.
The second mistake is letting the product interface bloat because one implementation wanted extra methods.
The third mistake is confusing taxonomy with design quality. A large hierarchy can still be a weak design if the variation points are wrong.
When reviewing product and creator hierarchies, ask:
A healthy hierarchy makes variation cheaper. An unhealthy one turns every new product into a multi-class ceremony.