The Ugly side of Dependency Injection

preview_player
Показать описание
How dependency injection hinders your ability to write declarative code and code re-usability in an ASP.NET Core app.

#aspnetcore #dependencyinjection #csharp
Рекомендации по теме
Комментарии
Автор

One thing to remember is that dependency injection is NOT IoC containers. The fact you’re passing in the db as an argument is actually dependency injection. Something to be used creates externally and passed in. People get too hung up on a library being the pattern.

stephenyork
Автор

I'd call it pragmatic. It doesn't seem to compromise anything I'd want to unit test so that is good. The tricky bit for a large team is ensuring that the technique is used appropriately and not misused. This is the classic trade-off, more effort in really thinking about your design can improve the maintainability/readability of the code. The question then is, does careful use of this approach pay its extra effort back over time? Versus the "just use DI everywhere approach". Not having used this approach I can't say but I get the feeling at least for large teams of varying experience this probably won't pay its effort back.

codingbloke
Автор

I would prefer a larger font size for your videos. Good content, keep it up!

patrickddd
Автор

I used to work with a project, that had SomethingStrategyFactoryFactoryDecorator, this seems so much cleaner :D

And yes, stay pragmatic!

Qrzychu
Автор

We need to keep pass parameter to the contructor..

tanoryjakaperdana
Автор

IMO, the biggest advantage to not using DI is that the compiler can save you. DI turns a compile time error into a rurntime error.

TECHN
Автор

Dependency Injection is absurd. Test-Driven Development is absurd(er). God, I hate "modern" development practices so much.

forevernoob
Автор

1) Your breaking the dependency inversion principal with the sauce (ViewCourseContext)
2) rather than a switch statement why not use the strategy pattern, that way you don't need to change ViewCourseContext every time you add a new query, just add a new query class and let the strategy pattern take care of the rest.
3) the last 2 videos have both shown you using the service locator pattern - you probably want to avoid making that seem like a general purpose go too pattern since technically it's an anti pattern and I'd hate for people to pick up bad habits, perhaps when you use this pattern you could explain when it's okay to use it.

shakeuk