It states that donโt repeat yourself what it means it is saying donโt duplicate code , avoid duplication. Purpose is to reduce the redundant code in your application ๐งตโฌ #dotnet
Following the DRY Principle can give us following benefits
Scenario, if you find yourself in a situation where multiple classes are using same properties then you can create a base class that will contain those repeated properties and you can inherit your class from it. #dotnet
DRY is not just limited to properties you have to apply at every point to avoid any kind of repetition methods/classes/properties etc.
โ Join 2100+ Software Engineers to receive a weekly tip of C# via my Newsletter (lnkd.in/dNHxJGRG)
HttpClient is a class in C# that is used for making HTTP calls of different kinds (most commonly Get/Put/Delete/Post).This class comes from namespace System.Net.Http
Most commonly used methods of this class are
- GetAsync
- DeleteAsync
- PostAsync
- PutAsync
- Dispose
๐กTracking vs Non Tracking Queries in .NET 1) Tracking Queries 2) Non Tracking Queries 3) Identity Resolution 4) How to set tracking by default for context๐งต๐ฝ #dotnet
๐๐ซ๐๐๐ค๐ข๐ง๐ : By default all queries are tracked , so behind the seen a change tracker keeps working on each entity. If you want to perform Update/Delete then you should use tracking. #dotnet
๐๐จ๐ง ๐๐ซ๐๐๐ค๐ข๐ง๐ : If you just need read only data then you don't need your queries to keep tracking of change , you can simply go with no tracking and help the query run more speedy. #dotnet
While working with .NET application we sometime come up with exception and we can deal with it in two ways , either by using try catch block in each class (controller level or service level) or we can define a centralized and global point to catch the exception. #dotnet
โ Pros of using Global Exception
1. It provides us a centralized error handling point and makes easier for us to manage.
2. Code readability is improved as we get rid of writing try-catch code in each method #dotnet