Dependency Inversion Principle and Hollywood analogy



Often DIP is known as the Hollywood principle: "Don't call us, we'll call you.".

But doesn't always higher level module calls lower level module, whether there is dependency inversion or not?

Then why is DIP called the Hollywood principle?

Am I missing something? Thanks!


Related to : Dependency Inversion Principle and Hollywood analogy
Difference between Inversion of Control & Dependency Injection
Programming Languages

IoC and DI concept were very much confusing for me so I read lots of views and post of different people and finally reach to the conclusion. So as I understand these topics are...

Inversion of control is a technique in java for making loosely coupled and more easily maintainable applications, and dependency injection is a one of the way to achieve this concept(technique).

Inversion of control container inject dependency at run time from java classes to make loosely coupled application.

Is this true ? correct me if I am wrong...


Understanding Inversion of Control and Dependency Injection
Programming Languages

I am learning the concept of IoC and DI. I checked a few blogs and below is my understanding:

A tight-coupling example without the use of IoC:

Public Class A
{
     public A(int value1, int value2)
     {
    return Sum(value1, value2);
     }

     private int Sum(int a, int b)
     {
    return a+b;
     }
}     

After IoC:

Public Interface IOperation
{
    int Sum(int a, int b);
}

Public Class A
{ 
     private IOperation operation;

     public A(IOperation operation)
     {
    this.operation = operation;
     }

     public void PerformOperation(B b)
     {
    operation.Sum(b);
     }
}

Public Class B: IOperation
{
   public int Sum(int a, int b)
   {
       return a+b;
   }
}

The method PerformOperation in Class A is wrong. I guess, it is again tightly coupled as parameter is hard coded as B b.

In the above example, where is IoC as I can see only Dependency Injection in the constructor of Class A.

Please clear my understanding.


Dependency Inversion Principle - Where should the interfaces go?
Programming Languages

I've been scratching my head about this for a few months and I've still been able to satisfactorily convince myself that I have the right answer. We have a, very typical, situation where we have dependencies between multiple layers of our application where each layer is in its own assembly. As an example, our application layer uses the repository layer to retrieve data so pretty standard. My question is, where would the abstraction (interface in this case) live and why? In the example given, should it go in the Application layer or the Repository layer or a separate abstractions assembly?

Based on the diagram and description in The Clean Architecture description (not something we're particularly adhering to) I've placed them in the Application layer so that all of the dependencies are pointing inwards but I'm not sure if this is right. I've read quite a few other articles and looked at countless examples but there is very little in the way of reasoning as to where the abstractions should live.

I've seen this question but I don't believe it answers my question unless of course the actual answer is it doesn't matter.


Dependency Inversion & Decoupling
Programming Languages

I'm wondering if someone might explain the last paragraph written in this example on Dependency Inversion & Decoupling.

http://www.springbyexample.org/examples/core-concepts.html

Following the example code, understanding the reasoning behind decoupling classes by implementing a base class is fine.

What I would like some clarification on is the last paragraph:

However, there is one problem with this implementation. We don’t have a main method. We > definitely need one in order to run our application, and somewhere in this main method we will need to instantiate the LocalVoteRecorder.

By instantiating the LocalVoteRecorder in our main method, we would break Rule #1 of Dependency Inversion. We have coded to the abstraction, we have integrated our changes, but our application would still have a dependency on a lower level class.

Does this mean it is not possible to create a truly decoupled application? How can it be that one could write a 100% decoupled application? Is it even necessary, and are there any best practices I could read up on.

Many thanks


What is meant by 'Inversion' in Dependency inversion
Programming Languages

I am learning spring. I understood dependency injection. In some place I also see it called dependency inversion. I got why it is termed as injection but what is meant by "inversion"? Which dependency is it actually inverting?


Dependency Inversion Principle and Hollywood analogy
Programming Languages

Often DIP is known as the Hollywood principle: "Don't call us, we'll call you.".

But doesn't always higher level module calls lower level module, whether there is dependency inversion or not?

Then why is DIP called the Hollywood principle?

Am I missing something? Thanks!



Privacy Policy - Copyrights Notice - Feedback - Report Violation - RSS 2017 © bighow.org All Rights Reserved .