kurumi
how can I avoid chaos like this ?
don't forget other snippets included: multiple functions to change console colors (aka
Console.SetRed() / Blue / Green / etc
), get all processes in OS (aka Processes.Google / notepad / vscode / etc
).
it is super useless18 replies
mapping a dynamic object to an existing object and only map properties that exist in the source obj
If the purpose is dynamicly changing values, it is better to use
JsonPatchDocument<T>
here is guideline https://learn.microsoft.com/en-us/aspnet/core/web-api/jsonpatch?view=aspnetcore-8.011 replies
✅ Dependency injection
now let's do some DI. Instead of controlling all dependencies inside of your SolarPanelService you tell: "Yeah, I have some things which I depends on (and they are also depends on others)", so you need to get them for your service, and now we call constructor:
16 replies
✅ Dependency injection
DI aka dependency injection is all about IoC (inversion of control).
Imaginary a situation when you are creating solar panels service. It needs to know what is the current weather. You have your weather service:
so you can normally use it for your solar panel service:
so, now take a look at this line
as you see your are creating your WeatherService inside of another service.
And now imagine that your boss told you to add logging into weather, then to add cache system, then to add email for some reason (idk, maybe boss wants to send weather email, XD).
So, it becomes more and more complex
so it is super complex now...
16 replies