Dependency injection and clean service registration | ASP.NET 5 REST API Tutorial 3

preview_player
Показать описание

Hello everybody I'm Nick and today I will show you how you can clean up your Startup file. We will make our service registration closed for modification and open for extension.

Don't forget to comment, like and subscribe :)

Social media:

#tutorial #rest #api
Рекомендации по теме
Комментарии
Автор

My thoughts have changed in this approach ever since, because it doesn't involve things like the order that services might need to be registered. I will be revisiting this in the future.

nickchapsas
Автор

God... friday ive been working on adding an Installer to our framework. Sunday, in order to improve a bit im watching your vids, and you're actually doing what im planning to do. The coincidence is just amazing.

macx
Автор

Very impressive coding skills. I'm enjoying the best practices

jaykbg
Автор

Thank you for this great course, Nick. We love you. However, apparently, there was no need to make it so concise, calling of the services. It's ok to have two lines instead of one. Below type of code looks perfectly fine and works great. What you did would help us to manage an assembly of services while there is actually no need of it now as you are introducing the basics; these optimization techniques should be kept out of scope in my view, just to avoid any feelings of complexes

public void services)

{

new DbInstaller().InstallServices(services, Configuration);
new MvcInstaller().InstallServices(services, Configuration);
}

Thank you once again for your contribution to the community of developers. You are an inspiration <3 :)

ashishdeora
Автор

Really like the clean startup and put everything in their own installer. Easy to add and remove without changing startup. Nice!

soucianceeqdamrashti
Автор

Hi Nick, was this approach revisited to install things in a certain order? Great series on REST with .NET Core by the way!

denizarca
Автор

Great videos my friend, helps a lot! one note, you need to increase the font, it is very hard to understand when it is so small. keep up with your good work man!!

dormelamed
Автор

This is simply amazing! So much to learn from you! Fabulous! Thank you, Nick! Your fan now.

ViragDesai
Автор

Thanks for your great in depth rest tutorial. Please make code font a little bigger. It would easy to follow on youtube.

MITHUNROYabir
Автор

Neat method. I tend to extend each DI containers to each project in a class named DependencyInjections.

So my Data Layer will extend services to add the dependencies needed for that layer.

Then in my startup I will run eg) services.AddData(); and services.AddBusiness();

PelFox
Автор

OMG, thanks for teaching us this amazing approach, I wander how many approaches like this in numerous projects in the world, it is absolute not friendly to beginners, people will easily get confused, but this is the necessary path to a master. Regarding to services registered order, I think at least we can keep the extension method, and remove foreach, or we can abstract another layer for orderless service than only loop it.

yuyuewang
Автор

Thanks for this tutorials about web services i cant find normal tutorual about this amazing thing. but i understand your videos its very easy and understandable.

faridmammadov
Автор

cool approach!
I'm curious how'd you unit test your DI registrations and startup class.
More importantly, where did you find the documentation and examples how to use startup class and ExportableTypes, Activator.CreateInstance methods.
I wanna learn all the features of startup and ways to manipulate it, but I'm struggling to find anything on the web.
Thanks Nick!

Vivalavidapool
Автор

1000 likes for this. I love your coding pattern, very clean.

sunnyokoro
Автор

Really nice and clean service registration, really loved it. Also I have a question: Do you think it's a good practice to write doc comments to all methods that I write or just code should be self-descriptive?

Really sorry for my english.

davidmiko
Автор

Great approach for cleaning up the startup code. I'm not sure that the DbInstaller would work with a multiple database server environments as the current 'DefaultConnection' only applies to one server/database.

davidpittman
Автор

Clean, and would work for independent services without any specific conditions! For others, this way can be avoided. Like, registration in a particular order, or registering a single kind of installer.

nayanchoudhary
Автор

I like this clean solution a lot! thanks :)

PatricSjoeoe
Автор

Great man 😍😍 Where were you till now 😬

shashankpandey
Автор

Isn't this basically the same as modules in ninject or structure map.
Normally the code that use the IServiceCollection is minimal, compared to the rest of the DJ.
Did i is missed something?

Sebastian----