While GoF patterns are ancient, Dependency Injection (DI) is the modern cornerstone of .NET development. It is the pattern that makes every other pattern on this list actually possible in a professional, unit-testable application.
In legacy code, a OrderService creates its own Database. In DI, the Service says: "Give me an IDatabase in my constructor. I don't care who created it or how it works." Control is inverted from the Service to the Framework.
This is the industry standard. It makes dependencies "Explicit." You cannot even instantiate the class without providing its requirements.
public class OrderService(ILogger logger) // C# 12 Primary Constructor
{
public void Process() => logger.Log("Processing...");
}
Because of DI, you can switch from SqlServerRepository to CosmosDbRepository by changing exactly ONE line of code in Program.cs. Your 50 Business Logic services never even realize the database has changed.
Q: "Why should we avoid the Service Locator pattern in favour of Constructor Injection?"
Architect Answer: "Service Locator (`_serviceProvider.GetService