Sitemap
Mohit Sharma

Mohit Sharma

Cause sometimes Writing > Talking

Member-only story

Callback Design Pattern

5 min readSep 8, 2025

--

Don’t call us, we’ll call you!

The Callback Concept

The “Callback” concept is all about library/framework code that “calls back” into YOUR code rather than the “traditional” (procedural) approach where YOU call code supplied as entry points by libraries. It is used for: customization (flexibility) and “event-driven” architectures (“actual” events OR “structuring of control-flow” [“pseudo” events])

“the Hollywood principle”: “don’t call us, we’ll call you” coinage: Richard E. Sweet, in “The Mesa Programming Environment”, SigPLAN Notices, July 1985

It describes Inversion of Control (IoC): instead of your app controlling when the framework runs, the framework controls the flow and calls your code at the right time. Hollywood principle (callback/event-driven): the framework owns the main loop. You just give it hooks (callbacks/delegates/listeners), and when something happens, it “calls you back.”

Implementation

“Callback” implementation give “somebody” a callable the “somebody” may store it “somewhere”

  • a container, an attribute, whatever or
  • even just keep it as a local variable

--

--

Mohit Sharma
Mohit Sharma

Written by Mohit Sharma

Cause sometimes Writing > Talking