r/learnprogramming • u/Bofact • 28d ago
Tutorial Dependency Injection confusing example
I am learning about Dependency Injection from the below link Dependency Injection in ASP comma NET MVC Tutorial | ASSIST Software, but in the first example is writing a prototype, in the second it creates "a separate class that has the responsibility of working with the database", but no class is created. He only implements the function from the example 1.
Am I missing something?
Edit: I initially put a link to the tutorial in question, but Reddit removed my post. So this is why this post doesn't have a link.
11
Upvotes
View all comments
1
u/DrDesperate 28d ago
tutorials do this a lot, they show the interface and then wave at the db class like it already exists. the whole trick is the controller gets handed the thing instead of building it itself, so you could swap in a fake one for testing.