Best of Dependency InjectionJuly 2025

  1. 1
    Article
    Avatar of csharpcornerC# Corner·43w

    Mastering Dependency Injection in .NET Core: A Complete Beginner-to-Advanced Guide

    Dependency Injection (DI) is a design pattern that promotes loose coupling, testability, and maintainability in .NET Core applications. The guide covers service registration in Program.cs, constructor injection, three service lifetimes (Transient, Scoped, Singleton), testing with mocked services, and advanced scenarios including factory-based registration and third-party containers like Autofac. Best practices include preferring interfaces over concrete classes, avoiding service locator patterns, and organizing registrations by feature modules.

  2. 2
    Video
    Avatar of kantancodingKantan Coding·43w

    The 3 Laws of Writing Testable Code

    Three fundamental principles for writing testable code: use dependency injection to decouple components, leverage interfaces to abstract external dependencies, and separate functions into single responsibilities. Demonstrates these concepts through a payment processing example, showing how to isolate code from external APIs like Stripe for effective unit testing.

  3. 3
    Article
    Avatar of lnLaravel News·44w

    Singleton and Scoped Container Attributes in Laravel 12.21

    Laravel 12.21.0 introduces singleton and scoped container attributes that can be applied directly to classes without manual registration. The release adds a whereValueBetween() query builder method for checking if values fall between two columns, strict validation options for numeric and boolean types, factory relationship controls, URI stringable conversion, and fluent empty check methods.