Tag: C#

C#

Why you should use early return in C#?

Today, I am going to share a simple technique that can improve the readability of your code: early return pattern. What is early return? In a method, there are usually the happy path (main logic) and the unhappy path (invalid input, invalid operation, etc.). Early return pattern is writing code such that when an unhappy […]

Sam Lau 
C#

Explain Dependency Injection Like I am Five

If you read posts about .NET or Microsoft’s documentations, you see the parse “dependency injection” (DI) a lot. Everyone say it is good practice and you should do it but what exactly is DI? Today, I will try to explain dependency injection like you are five. Dependency Inversion Before talking about dependency injection, let’s talk […]

Sam Lau