In programming, a decorator is a design pattern that allows you to modify or enhance the behavior of a function or method without changing its actual code. It acts as a wrapper around the original function, adding new functionality before or after the original code runs. This is commonly used in languages like Python to implement features such as logging, access control, or caching.
Decorators are defined using the "@" symbol followed by the decorator function name, placed above the function to be decorated. They help keep code clean and maintainable by separating concerns, allowing developers to apply the same enhancements to multiple functions easily.