design-patterns

  • Probabilistic early expiry beats a lock

    Rather than coordinating who recomputes, let each reader decide independently with a probability that rises as the expiry approaches — so one request refreshes early and the rest…

  • Test doubles for an interface you do not own

    Mocking a third-party class binds the test to that class’s current signature, so an upgrade changing a method leaves the test passing against a shape that no longer…

  • Read models can be stale and must say so

    A projection updated asynchronously is behind by some amount, usually milliseconds and occasionally minutes. Hiding that from the caller makes every consumer assume it is current, and one…

  • WooCommerce 3.0 turned products into objects

    Every plugin reading _price from post meta is now reading a private field. The mechanical half, the half that is not, and the compatibility layer for code you…

  • An entity has identity; a value object does not

    Two customers with the same name are different customers; two amounts of 49.00 TRY are the same amount. That distinction decides equality, mutability and whether the thing needs…

  • CSS Grid arrived, and the layout hacks can go

    Chrome 57 and Firefox 52 shipped it a fortnight apart in March. Replacing a grid system of nested rows, negative margins and a clearfix with fourteen lines.

  • Queues, workers and the jobs that fail twice

    The email that arrived four times and the charge that arrived twice. What makes a job safe to run again, and keeping workers alive without them serving stale…

  • CQRS is two models, not two databases

    The pattern gets introduced alongside event sourcing, separate stores and eventual consistency, which makes it look like an architecture. The idea underneath is smaller: the shape that is…

  • Redis beyond caching: locks, counters and rate limits

    The cache server was already there doing one job out of four. A lock that expires, a release that checks it still owns the lock, and a sliding-window…

  • Laravel 5.3 notifications unified the channels

    Sending the same event by email, SMS and a database record meant three call sites and three formats to keep in step. 5.3 makes the notification one class…