ASP.NET Core Dependency Injection
When working with Object-Oriented Programming model, everything is basically treated as an object which is to be used to access a class. We also create a lot many objects when we are working in a complex application and if we forget to implement any design pattern to decide the creation and lifetime of those objects, it becomes very difficult since even if any small change comes in future for our application, we will have to change lots of code for that small change.
That is why it is advised to use design patterns in our application, one of which is Dependency Injection which I will cover in this blog, so let’s begin.
Dependency Injection means when an object depends upon some other objects and these objects are known as dependencies.
Let us understand this with a very simple example –
Let’s suppose we have to make a cake. Now in order to make a cake we need eggs which is provided to us by the hen. We are basically depending on the hen to produce eggs and we can use them to prepare our cake. We don’t care how the eggs are produced. We will be delivered the eggs once the eggs come to the shopkeeper.
DOJ: 07 Oct 2020