Principles
Hollywood Principle: Stop Polling and Get Called
The Hollywood Principle says low-level parts should not call the source to ask whether something happened; the source calls them. It removes the guessing that polling needs. These lessons refactor a shop where packing and invoicing poll the checkout into one where the checkout notifies its listeners.
Pick your language
When to use it
Use it when
Several parts must react when something happens in one place, like an order being placed.
Skip it when
The source can't call you, like a third-party service with no callback or webhook. Then polling is the only choice.
Spot it by
A counter like lastSeen, or a loop that asks the source each tick whether anything is new.