design-patterns

  • Idempotency keys, and where they have to be stored

    A client that times out and retries has sent the same request twice, and the server cannot tell whether the first one succeeded. The key makes the retry…

  • Bootstrap 4 dropped the float grid

    Two and a half years in alpha, and the grid is flexbox now. The class renames are mechanical; the ones that changed meaning rather than name are not.

  • A macro is how you extend a framework class without extending it

    Adding a method to a collection or a response means subclassing, and subclassing a framework class means every place that constructs one has to know about your subclass.…

  • The 5.5 exception that renders itself

    Custom exceptions have always had to be translated into a response somewhere in the handler, which turns one file into a growing chain of instanceof checks. 5.5 lets…

  • A circuit breaker before the third-party outage

    A payment provider was slow and the whole site went down with it. A timeout bounds one request; it does nothing about how many are waiting at once.

  • Mailable classes and why the view is not the email

    An email assembled in a controller — subject here, view there, attachments in a third place — cannot be tested without sending it, and the subject line ends…

  • Designing an API two mobile clients can live with

    Two apps, two release cycles, and neither can be forced to update. What is additive, what is not, and the decisions that have to be made before the…

  • A circuit breaker has three states and people implement two

    Closed and open are obvious: pass through, or fail fast. The third state is what makes it a breaker rather than a switch — half-open lets exactly one…

  • A saga is a workflow with compensation, not a transaction

    A distributed transaction is not available, so the pattern is: do each step, and if a later one fails, run compensating actions to undo the earlier ones. Compensation…

  • An event-driven seam between two services

    The synchronous call between two services was the reason both were down. Publishing an event decouples their availability — and makes eventual consistency a business decision.