jeudi 4 mai 2017

Confusion between Inversion of Control and Hollywood Principle

I am reading Head First Design pattern and just stuck on the Hollywood Principle. Earlier I read about Inversion of Control and what I understood was, it's a design principle (some also call it pattern) through which conventional flow of program changes from "Higher level module calling Lower level module" to "Lower level module calling Higher level module" (generally through abstractions), so we can have very low dependency on specific low-level module and changing low-level modules does not have any impact on our higher level or near to business modules.

But I got confused when the author said the following line regarding the Hollywood principle:-

With the Hollywood Principle, we allow low-level components to hook themselves into a system, but the high-level components determine when they are needed, and how. In other words, the high-level components give the low-level components a “don’t call us, we’ll call you” treatment.

In the last line, it is said that The high-level components give the low-level components a “don’t call us, we’ll call you” treatment. This means our high-level components are actually calling low-level components and hence this seems to break the Inversion of control principle and also Dependency Inversion principle.

Please clarify on this.

Aucun commentaire:

Enregistrer un commentaire