Observer: Define a one-to-many dependency so that when one object changes state, all its dependents are notified and updated automatically. The Observer pattern lets objects subscribe to changes in another object. When the subject changes, it notifies all its observers automatically, without knowing who they are or what they do. Laravel's model observers and event listeners follow this pattern. When an order is created, observers can send a confirmation email, update stock and notify the warehouse, while the order code stays unaware of all of them.
This keeps code loosely coupled and easy to extend. The downside is that behaviour is spread out, so it is not obvious from the order code what happens on save. Keep observers focused, document what listens to what, and move slow work like emails and API calls to queued listeners so they do not slow down the original request. Be careful with observers that trigger other observers.
Implement proven backend architecture patterns including Clean Architecture, Hexagonal Architecture, and Domain-Driven Design. Use this skill when designing clean architecture for a new microservice, when refactoring a monolith to use bounded contexts, when implementing hexagonal or onion architecture patterns, or when debugging dependency cycles between application layers.
'Cloud design patterns for distributed systems architecture covering 42 industry-standard patterns across reliability, performance, messaging, security, and deployment categories. Use when designing, reviewing, or implementing distributed system architectures.'