A software example
The Django framework uses decorators to a great extent. An example is the View decorator. Django's View decorators can be used for [j.mp/djangodec]:
- Restricting access to views based on the HTTP request
- Controlling the caching behavior on specific views
- Controlling compression on a per-view basis
- Controlling caching based on specific HTTP request headers
The Grok framework also uses decorators for achieving different goals such as [j.mp/grokdeco]:
- Registering a function as an event subscriber
- Protecting a method with a specific permission
- Implementing the Adapter pattern