Interpreter:Represent a Grammar and Evaluate It
Model a tiny promo DSL as AND/OR of percent-off and sku-in-category expressions that evaluate(Order), and skip it when a few ifs or a real parser would be honest.
Read More31 post(s)
Model a tiny promo DSL as AND/OR of percent-off and sku-in-category expressions that evaluate(Order), and skip it when a few ifs or a real parser would be honest.
Read MoreAdd CSV export and tax walks to a stable Sku / Category tree with accept(Visitor) so each new report is a class, not another method on every catalog type.
Read MoreClone a configured DiscountPolicy, ChargeRequest, or gateway test double in Java instead of rebuilding constructor arguments — and skip clone() when new is cheaper or the copy shares mutable guts.
Read MoreUndo a checkout draft in Java by letting Order take an opaque snapshot — no public fields, no JSON dump, and no serializing OrderProcessor.
Read MoreStop DiscountPolicy, PaymentGateway, fraud, inventory, and the notifier from importing each other by letting CheckoutMediator own the checkout conversation.
Read MoreShare immutable catalog SKU metadata across cart LineItems so a Black Friday order does not clone name, tax class, and image URL on every row.
Read MoreStop the Email×SendGrid / SMS×Twilio subclass grid by letting OrderNotifier hold a MessageSender so channels and vendors vary independently.
Read MoreStop walking Order line items with get(i) on a leaked ArrayList so a switch from list to a SKU tree does not rewrite OrderProcessor.
Read MoreBuild Stripe-region and Razorpay-region checkout families in Java so gateway, webhook parser, and money type vary together without OrderProcessor naming the concretes.
Read MoreReplace a hard-coded fraud-inventory-payment-notify sequence with a Handler chain in Java so a new checkout step is a class you splice in, not a next-type you edit.
Read MoreReplace a growing DRAFT / PAID / REFUNDED / VOID switch in process, refund, and void with OrderStatus objects that own legal transitions, so OrderProcessor stops being the state machine.
Read MoreReplace nested loops over Outdoor / Hiking / SKUs with a CatalogNode tree so a category and a single product both answer subtotal(), and OrderProcessor still charges one payable.
Read MorePut a PaymentGateway proxy in front of a slow SDK so OrderProcessor still calls charge, while lazy init, an auth check, and a last-result cache decide whether the real gateway runs.
Read MoreTurn charge, refund, and capture into Java objects you can queue, retry, undo, or audit — without wrapping a one-shot process() in ceremony.
Read MoreHide checkout’s discount, payment, fraud, and tax conversation behind one CheckoutFacade.place(Order) so controllers stop assembling the subsystem.
Read MoreFreeze a shared Java payment sequence so capture, refund, and void keep one skeleton and only the provider step (and hooks) vary.
Read MoreKeep a process-wide resource as an enum singleton only when you can name why there must be one, and inject Clock, config, and gateways into OrderProcessor instead of AppContext.getInstance().
Read MoreReplace a telescoping ChargeRequest constructor with a Java builder so required checkout fields stay required, optional ones stay optional, and the product can still be a record.
Read MoreWrap a vendor client whose methods do not match PaymentGateway so OrderProcessor keeps calling charge(Order, BigDecimal) and never learns PayPal’s shape.
Read MoreReplace AuditedRetryingCachedGateway subclasses with PaymentGateway wrappers you compose at the edge — logging, retry, cache — without a new type per combination.
Read MoreStop editing OrderProcessor for every new notification channel by publishing a payment event and letting EmailNotifier and AuditLog subscribe.
Read MoreMove construction of DiscountPolicy and PaymentGateway behind a polymorphic creator so six controllers stop naming PercentOff and StripeGateway.
Read MoreReplace a growing discount if/else with a Strategy in Java so each new promotion is a class you add, not a branch you edit into OrderProcessor.
Read MoreA map of creational, structural, and behavioral patterns — what pain each one solves, when to skip it, and links to every post in this series.
Read MoreWalk one order/payment notification service through all five SOLID principles end to end — the seams that matter, the ones that do not, and when to stop applying the checklist.
Read MoreApply Dependency Inversion in Java: move Stripe and SMTP construction out of OrderProcessor, inject abstractions, and see how Spring DI is one wiring option — not the principle itself.
Read MoreApply Interface Segregation in Java: break a fat PaymentOperations interface into client-shaped seams so charge, refund, and report clients stop stubbing unused methods.
Read MoreSpot Liskov Substitution violations in Java inheritance — UnsupportedOperationException, tightened preconditions, null surprises — and replace dishonest subtypes with honest types.
Read MoreApply the Open-Closed Principle in Java: replace growing if/switch payment forests with extension seams so new providers are added, not edited into the core.
Read MoreWhat the Single Responsibility Principle actually means — one audience, one reason to change — with a Java OrderProcessor god class split into cohesive pieces.
Read MoreWhat SOLID means in practice, a glossary of the five principles, when they become cargo-cult, and a map of this series — with a shared order/payment domain for later posts.
Read More