jargon

Comparison

Hollywood principlevsInversion of control

Hollywood principle

you register your code and something else decides when it runs, which is the opposite of how a library feels.

The one-line statement of inversion of control: don't call us, we'll call you. It is the distinction between a library, which you call, and a framework, which calls you, and it is what template method, observers and lifecycle hooks all have in common. Useful mostly as a way to explain inversion of control in a sentence someone will remember.

Full entry →

Inversion of control

you stopped writing the loop and started writing the thing the framework calls, and you no longer decide when.

The general shift where a framework owns the flow of control and your code fills in the parts, rather than your code calling a library when it chooses. Dependency injection is one specific case of it — control over which object you get — but so are event handlers, template methods and lifecycle callbacks. Confusing the general idea with the specific technique is the most common wrong answer to the interview question about the difference.

Full entry →

Related comparisons