Senior Software Engineer (.NET) | Tweets and threads are related to C# and .NET
Aug 2, 2023 โข 8 tweets โข 3 min read
Multiple ways to create middleware in .NET?
It is software assembled into an app pipeline to handle requests and responses. In simple, it gives us the facility to add additional logic before and after the HTTP request.
๐๐ผ๐ ๐ฑ๐ผ๐ฒ๐ ๐บ๐ถ๐ฑ๐ฑ๐น๐ฒ๐๐ฎ๐ฟ๐ฒ ๐๐ผ๐ฟ๐ธ ๐
Suppose we have three middleware in our app then for each middleware we enter two times.
First middleware logic is performed then we send it to the next middleware
Jun 26, 2023 โข 9 tweets โข 3 min read
What is SOLID , why we need these principles and S explained ?
It is combination of 5 design principles
S - Single Responsibility Principle (SRP)
O - Open/Closed Principle (ORP)
L - Liskov Substitution Principle (LSP)
I - Interface Segregation Principle (ISP)
Thread ๐งต๐
D - Dependency Inversion Principle (DIP)
Why we need SOLID or its benefits
- Better Testability
- Reduces coupling
- Removes Duplication
- Increases Readability
- Increases Extensibility
SRP says :-
- A class/method should have one reason to change
Jun 20, 2023 โข 10 tweets โข 9 min read
Are you struggling to find right resources to learn C# and .NET then check these out ?
- Properties are first class citizens in C#
- We used properties to achieve abstraction
- Properties are implemented via accessors
- Enable developers to write code that accurately expresses their design intent #dotnet
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
#dotnet
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
Apr 9, 2023 โข 5 tweets โข 2 min read
๐ก 15+ .NET Libraries you should Know
Now a days libraries play an important role in your development, start learning these librariesย for a good development experience.
- Mediator for CQRS
- Dapper for micro-ORM
See more๐งตโฌ #dotnet
- Serilog and NLog for logging
1) Whatis IEnumerable 2) What is IQueryAble 3) Difference b/w them โฌ
#csharp#dotnet
IEnumerable and IQueryable interfaces are both used to work with collections of data and both support LINQ (Language Integrated Query) #dotnet
Mar 21, 2023 โข 7 tweets โข 3 min read
๐ก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
Mar 20, 2023 โข 5 tweets โข 3 min read
๐กGlobal Error Handling in .NET ? 1) Why we need it 2) Pros and cons 3) Code implementation๐งต๐ฝ
#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
Mar 18, 2023 โข 10 tweets โข 2 min read
๐กResponse Caching in .NET
1. Introduction 2. How to implement it 3. Code 4. Benefits 5. Constraints 6. Real examples๐งต๐ฝ
#csharp #dotnet
It is a technique for storing the responses of an API in a cache so that they can be served faster to sub sequent requests.
Responses is stored with a key that uniquely identifies them, the cache has a limited size and a policy for removing items when it becomes full
#dotnet
Mar 13, 2023 โข 5 tweets โข 2 min read
๐ก Life of Query in EF
๐๐ญ๐๐ฉ ๐ : The LINQ Query is processed by EF Core and build an representation that is processed by database provider, and the result is cached later on so we don't need to process it every time #dotnet
See thread ๐งตโฌ
๐๐ญ๐๐ฉ ๐ : The result is passed to the db provider and db provider identifies which parts of query can be evaluated in db, these parts are then translated into query language (e.g. SQL) after that translated query is sent to db and db returns results (but not entity instances)
Mar 12, 2023 โข 8 tweets โข 4 min read
๐ก 7 Tips to write better LINQ Queries
๐๐ฌ๐ ๐จ๐ ๐๐ฌ๐๐จ๐๐ซ๐๐๐ค๐ข๐ง๐ : For read only queries e.g. (GetAll,GetById etc.) use AsNoTracking , when we use it entities are not tracked for change so it brings data more speedily. #dotnet
See thread ๐งต๐ฝ
๐๐ง๐๐ฅ๐ฎ๐๐ ๐ง๐๐๐๐ฌ๐ฌ๐๐ซ๐ฒ ๐๐ง๐ญ๐ข๐ญ๐ข๐๐ฌ ๐๐ง๐ ๐๐จ๐ฅ๐ฎ๐ฆ๐ง๐ฌ : While retrieving data from multiple table make sure to include only necessary tables and columns Use eager loading only when it is necessary. #dotnet
Mar 11, 2023 โข 7 tweets โข 2 min read
๐ก How to store Password in Database
Three common practices that are used for passwords, but first two has some serious issues.
โ๏ธ Plain text password
โ๏ธ Hashed password
โ๏ธ Hashed password with Salt
โ๏ธWhat is Salt
โ๏ธHow to validated hash password
#csharp#dotnet
1๏ธโฃ Plain Text Password
Saving password in plain text is the worst approach because it is open to everyone who has database access and an easy target for attackers. Its not recommended at all.
Feb 27, 2023 โข 8 tweets โข 2 min read
๐ก Do and Don't for string in C#
1. Always use 2. Don't use ๐
โ๏ธIf you like my tweets, please join 400+ Software Engineers to receive an actionable tip weekly in your inbox through my Newsletter.(lnkd.in/d69Va5CM)
#csharpย #dotnetย #dotnetcore
โ Use an overload of theย String.Equalsย method to test whether two strings are equal
โ Use theย String.Compareย andย String.CompareToย methods to sort strings, not to check for equality.
Feb 26, 2023 โข 9 tweets โข 3 min read
Method Safety and Idempotency
1. HTTP Methods Introduction 2. Method safety with examples 3. Method Idempotency with examples
๐งตโฌ
#csharp#dotnet#dotnetcore
GET is used to retrieve data, POST is used to save, PUT is used to update existing data edit is common example of it, PATCH is lighter version of PUT , it is used to update just a specific information instead of updating all data on server DELETE is used to remove records.