News for hackers. Stuff that matters.
Re:Compile-Time DI vs. Run-Time DI by sagichmal on Tuesday April 30, 2019 @03:29PM (#19791092)
Oh, sorry. twic basically got what I meant. I'd expand the example a bit to demonstrate how to use different implementations of things:

    var db IDatabase
    {
        if dev_mode  
            db = new InMemDatabase()
        else
            db = new PostgresDatabase(dsn)
    }
    var users = new UsersRepository(db)
    var catalogue = new ProductRepository(db)
    // ...
    var cart = new ShoppingCartController(users, catalogue, logger, metrics, ...)

There are no comments on this comment yet.