News for hackers. Stuff that matters.
Re:Inversion of Control Containers and the Dependency Inject... by javcasas on Thursday February 22, 2024 @06:28AM (#39465623)
> Like many architecutral design patterns, toy examples don't illustrate the concept well. It's used for doing things like switching a large service-based system from using external databases and remote services for production, to in-memory everything for testing.

You know, if the DB is passed as a parameter, I can do that too. Without @inject, or XML, or the god container object.

    const testdb = new InMemoryDB();
    const result = await myThing(testdb);
  expect(result.foo).toBe(42);
    expect(testdb.rows).toEqual(bar);

There are no comments on this comment yet.