If you are browsing in a bookstore or reading articles on the Internet, you will probably often see a high-looking word called Dependency Injection (DI). think that it is related to SQL Injection, but after reading it, I found that there is no connection at all. So this time let’s share the concept of DI. Basically, the concept of DI has been around for more than ten years, but many people are still not familiar with it.
If you design a program completely intuitively, it may flow like a waterfall from beginning to end, and you will do whatever comes to mind. But if you don’t point out areas where programs are duplicated or have similar structures, you will not only keep doing canada dataset the same thing over and over again, but it will also make testing difficult and cause a waste of efficiency. Because every time you need to make program changes for small differences.
At this time, the concept of DI comes to save tired engineers! There are many ways to use it. First, let’s talk about its usage. Taking the architecture of ASP.Net Core as an example, his steps are roughly as follows: Create an Interface and declare properties and methods Create Service and inherit Interface Register the service in Startup's Configuration. This can map class implementations to Interfaces Inject service dependency objects into Controller, Action or View.