Muhammad Waseem Profile picture
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.

๐—›๐—ผ๐˜„ ๐—ฑ๐—ผ๐—ฒ๐˜€ ๐—บ๐—ถ๐—ฑ๐—ฑ๐—น๐—ฒ๐˜„๐—ฎ๐—ฟ๐—ฒ ๐˜„๐—ผ๐—ฟ๐—ธ ๐Ÿ‘‡ Image 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 Image
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 ?

๐˜๐จ๐ฎ๐“๐ฎ๐›๐ž ๐‚๐ก๐š๐ง๐ง๐ž๐ฅ๐ฌ
- Dotnet (bit.ly/3L2CUqn)
- Edureka (bit.ly/3GLdT0k)
- Brackeys (bit.ly/3zYDMWA)
- Kudvenkat (bit.ly/3MGsSfK)๐Ÿงต๐Ÿ‘‡

#dotnet - QuestPond (bit.ly/3N303KP)
- Nick Chapsas (bit.ly/3MKFhiz)
- Derek Banas (bit.ly/41wU9FM)
- Milan Jovanoviฤ‡ (bit.ly/3zXoPEi)
- I am Tim Corey (bit.ly/3UD0zAI)
- FreecodeCamp (bit.ly/3GMDVQC)
Jun 18, 2023 โ€ข 5 tweets โ€ข 2 min read
Why should we use NodaTime over Default .NET DateTime ?

These are the 7 reasons

1) Lack of clarity in DateTime especially when comparing local and UTC times๐Ÿ”ฝ๐Ÿ‘‡

#dotnet Image 2) DateTimeKind property and various operations like ToUniversalTime() and ToLocalTime() can lead to unexpected results

3) DateTime does not provide a comprehensive solution for handling time zones.

#dotnet
Jun 14, 2023 โ€ข 4 tweets โ€ข 2 min read
Are you using required keyword with properties ?

Since C# 11 we can add required keyword with properties , it will force to initialize that property at the time of object creation.

There are few benefits of using it
- Less chance of error
- Get rid of validation code

#dotnet Image - If something is essential make it required

Compiler will give error if you don't initialize that property.

๐Ÿ“Œ P.S:- If you enjoy reading my posts join my weekly .NET Newsletter. Join with 3400+ :

#dotnetlnkd.in/dNHxJGRG
May 13, 2023 โ€ข 8 tweets โ€ข 4 min read
What is the difference b/w field and property , what are the different types of properties in C# ?

- Properties
- Field vs Properties
- 6 Types of Properties

#dotnet Image Properties vs Field

- 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 Image
Apr 29, 2023 โ€ข 5 tweets โ€ข 3 min read
๐Ÿ’ก๐ƒ๐จ๐งโ€™๐ญ ๐‘๐ž๐ฉ๐ž๐š๐ญ ๐˜๐จ๐ฎ๐ซ๐ฌ๐ž๐ฅ๐Ÿ (๐ƒ๐‘๐˜) ๐๐ซ๐ข๐ง๐œ๐ข๐ฉ๐ฅ๐ž

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 Image Following the DRY Principle can give us following benefits

1.ย  Improved maintainability of code

2.ย  Reduces the risks of bugs

3.ย  Code becomes easier to understand

#dotnet
Apr 17, 2023 โ€ข 7 tweets โ€ข 3 min read
๐Ÿ’ก NULL Operators Guide in C#

- Ternary Operator (? :)

- Null Forgiving Operator (!.)

- Null Conditional Operator (?.)

- Null Coalescing Operator (??)

- Null Coalescing Assignment Operator (??=) ๐Ÿงตโฌ

#dotnet Image Ternary Operator or Conditional Operator(?.) ย is used to evaluate a condition and then we can do something on that basis for true and false

#dotnet
Apr 16, 2023 โ€ข 5 tweets โ€ข 2 min read
๐Ÿ’กHTTP Client Class in C#

. Introduction
Methods
Properties
Dependency injection ๐Ÿงตโฌ

#dotnet Image 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 Image - Serilog and NLog for logging

- Bogus for fake data generation

- Fluent Validation for validations

- SignalR for real time communication

- Moq for mock interfaces and classes

- Hangfire and Quartz for background jobs

- Noda Time best in the town for date-time

#dotnet
Mar 22, 2023 โ€ข 7 tweets โ€ข 3 min read
๐Ÿ’กIEnumerable vs IQueryAble in .NET

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 Image 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 Image 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

#dotnet

#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 Image 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.