Schematex
umlclass·OMG UML 2.5.1 §9–§11·software·complexity 2/3·since v0.6.4

Payment strategy pattern with enum + custom stereotype

The Strategy pattern as a UML class diagram — a payment service depending on an interface that three concrete strategies realize, plus an enumeration for the supported methods and a custom «service» stereotype.

For the application architect

Open in Playground →
umlclass·§
↘ preview
100%
Payment strategy UML class diagram: 1 enum, 1 interface, 4 class; 3 realization, 2 dependency; 1 merged inheritance tree. Payment strategy «enumeration» PaymentMethod CARD BANK_TRANSFER WALLET «interface» PaymentStrategy + authorize(amount: Money): AuthResult + capture(auth: AuthResult): Receipt «service» CheckoutService - strategies: Map<PaymentMethod, PaymentStr… + pay(method: PaymentMethod, amount: Money)… CardStrategy + authorize(amount: Money): AuthResult + capture(auth: AuthResult): Receipt BankStrategy + authorize(amount: Money): AuthResult + capture(auth: AuthResult): Receipt WalletStrategy + authorize(amount: Money): AuthResult + capture(auth: AuthResult): Receipt delegates to delegates to selects by selects by
UTF-8 · LF · 29 lines · 889 chars✓ parsed·4.3 ms·10.6 KB SVG

Reading the diagram

The Strategy pattern is one of the canonical Gang-of-Four examples and is almost always introduced as a UML class diagram for a reason: a single picture says exactly what an interface-based design buys you.

«enumeration» and «service» are both stereotypes. The enum keyword is a standard UML stereotype that swaps the rendering: literals sit in the attribute compartment without visibility glyphs, and there's no operations compartment populated. The «service» keyword on CheckoutService is a custom stereotype — any guillemet-wrapped word above a class name. Custom stereotypes are how teams tag classifiers with their architectural role («service», «controller», «entity», «repository») without inventing new visual primitives.

Realization vs dependency at a glance. The three concrete strategies realize the interface — dashed line, hollow triangle, drawn three times pointing at the same interface (a future render pass may merge the triangle heads into a single shared head). The CheckoutService's relationship is a dependency — it uses both PaymentStrategy and PaymentMethod through its public API but does not commit to a structural containment. The dashed-line-with-open-arrow encoding makes the using-relationship visible without implying ownership.

The Map<PaymentMethod, PaymentStrategy> attribute type renders inline as text — generic type names are part of v0.1; parameterised classifier boxes (List<T>) are deferred.

UML class diagram syntax