DELAPARRA
Index
Color
NL
Category: Programming paradigms

Advice

Explained by Updated

What is Advice?

Advice: The actual code that runs at a join point — before, after, or around it. In aspect-oriented programming, advice is the code that runs at a chosen point in your program, called a join point. It can run before the original code, after it, or around it, in which case it decides whether the original runs at all.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about Advice

How is Advice used in practice?

A logging advice might record every call to a payment method. A transaction advice might open a database transaction before a service method and commit or roll back afterwards.

What should you keep in mind with Advice?

The idea shows up in many frameworks under other names. Laravel middleware runs around a request, and model events run before or after saving. These are all forms of advice. The trade-off is visibility. When behaviour is added from elsewhere, the function you are reading does not show everything that happens when it runs, so keep the amount of hidden behaviour small and well documented.

At a glance

CategoryProgramming paradigms
Explained by
Updated

More Programming paradigms terms

All terms starting with A

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.