Why Dependency Injection Is Not a Design Substitute

1. Introduction: Dependency Injection Solves Construction, Not Design

Dependency Injection is one of the most useful techniques in modern application development.

It helps separate object creation from object use. It makes dependencies visible through constructors. It allows infrastructure services to be replaced in tests. It supports configuration, lifetime management, composition, and application startup. It can reduce hard-coded dependencies and make systems easier to assemble.

Those are real benefits.

But Dependency Injection does not design the application.

It does not decide which responsibilities belong together.

It does not decide which dependencies are appropriate.

It does not decide whether a service has too many reasons to change.

It does not decide whether an interface represents a meaningful boundary.

It does not decide whether the application code speaks in the language of the workflow.

It only decides how objects are supplied to other objects.

That distinction matters.

A class can receive all of its dependencies through its constructor and still have poor design.

For example, a service may be fully injected:

public sealed class OrderService
{
    private readonly IOrderRepository _orderRepository;
    private readonly ICustomerRepository _customerRepository;
    private readonly IEmailSender _emailSender;
    private readonly IPaymentGateway _paymentGateway;
    private readonly IDiscountCalculator _discountCalculator;
    private readonly IInventoryClient _inventoryClient;
    private readonly ILogger<OrderService> _logger;
    
    public OrderService(
        IOrderRepository orderRepository,
        ICustomerRepository customerRepository,
        IEmailSender emailSender,
        IPaymentGateway paymentGateway,
        IDiscountCalculator discountCalculator,
        IInventoryClient inventoryClient,
        ILogger<OrderService> logger)
    {
        _orderRepository = orderRepository;
        _customerRepository = customerRepository;
        _emailSender = emailSender;
        _paymentGateway = paymentGateway;
        _discountCalculator = discountCalculator;
        _inventoryClient = inventoryClient;
        _logger = logger;
    }
}

Nothing in this constructor is necessarily wrong by itself.

Each dependency may be useful. Each interface may have an implementation. Each service may be registered correctly in the container. The code may compile, run, and be testable with mocks.

But the constructor raises design questions.

Why does this service need so many collaborators?

Does it represent one use case or several?

Is it coordinating a workflow, or has it become a place where many unrelated decisions meet?

Are all of these dependencies part of the same responsibility?

Could some of the work belong in smaller application services, domain policies, infrastructure adapters, or dedicated workflow components?

Dependency Injection makes those questions visible.

It does not answer them.

That is the central point.

DI is a composition mechanism.

Design is a responsibility decision.1

DI can help the design by making dependencies explicit, but it cannot replace the design work itself.

DI Wires Objects; Design Chooses Responsibilities

Dependency Injection can wire the object graph, but design still decides which responsibilities and dependencies belong together.

This is especially important because DI often creates an illusion of cleanliness.

A class that does not use new directly may look decoupled.

A dependency hidden behind an interface may look flexible.

A service registered in the container may look architectural.

A test that replaces dependencies with mocks may look well-isolated.

But those signals can be misleading.

A class can depend on an interface and still depend on the wrong concept.

A service can be mockable and still have unclear responsibility.

A container can register many services without creating meaningful boundaries.

A constructor can expose dependencies without proving that those dependencies belong there.

For example:

public sealed class ArticlePublishingService
{
    private readonly IArticleRepository _articleRepository;
    private readonly IUserContext _userContext;
    private readonly IEmailSender _emailSender;
    private readonly IAnalyticsTracker _analyticsTracker;
    
    public ArticlePublishingService(
        IArticleRepository articleRepository,
        IUserContext userContext,
        IEmailSender emailSender,
        IAnalyticsTracker analyticsTracker)
    {
        _articleRepository = articleRepository;
        _userContext = userContext;
        _emailSender = emailSender;
        _analyticsTracker = analyticsTracker;
    }
}

This may be a good design.

Or it may not be.

The answer does not come from the fact that the dependencies are injected.

The answer depends on what the service is responsible for.

If publishing an article includes checking permissions, changing article state, notifying subscribers, and tracking an event, these dependencies may belong together as part of one workflow.

If the service also edits drafts, generates previews, imports metadata, manages newsletter templates, and writes audit records, the same constructor may be a warning sign.

DI shows the shape of the dependency graph.

It does not tell us whether the shape is meaningful.

That requires design judgment.

The same is true for interfaces.

An interface can be helpful when it represents a boundary, variation point, external dependency, or stable contract.

But an interface can also be created only because the DI container needs something to register or because a test wants something to mock.

That can lead to many interfaces that do not express meaningful abstractions.

public interface IOrderService
{
    Task ProcessAsync(
        OrderRequest request,
        CancellationToken ct);
}

This interface may be useful if different implementations exist or if callers need a stable boundary.

But if there is only one implementation, no meaningful boundary, and no clear concept beyond “whatever the current service does”, the interface may not add much design value.

It may only make the code look more abstract.

Dependency Injection can support abstraction.

It cannot make an abstraction meaningful.

This article is not an argument against DI.

Quite the opposite.

DI is valuable when used as a supporting mechanism. It helps assemble the system. It keeps construction decisions near the composition root. It allows infrastructure details to be supplied from the outside. It makes dependencies visible enough to discuss.

But that visibility should lead to design questions.

  • When a constructor grows, ask what responsibility is growing.
  • When an interface is introduced, ask what boundary it protects.
  • When a service is registered, ask what role it plays in the application.
  • When a dependency is mocked, ask whether the test is isolating behavior or only verifying calls between procedural pieces.

A useful question is:

If the DI container disappeared, would the design still make sense?

If the answer is no, the design may depend too much on the container and not enough on clear responsibilities.

A good design should still be understandable without looking at the registration code.

It should be clear which objects represent workflows, which objects represent policies, which objects adapt infrastructure, which objects hold state, and which objects translate between boundaries.

DI can wire those pieces together.

It cannot decide what the pieces should be.

That is why Dependency Injection is not a design substitute.

It solves construction.

Design still has to solve responsibility.

2. DI Can Make Poor Dependencies Easier to Hide

Dependency Injection is often introduced to reduce direct coupling.

Instead of a class creating its own dependencies, those dependencies are provided from the outside. That can make the code more flexible. It can make dependencies easier to replace. It can move construction decisions out of the class and into the composition root.

That is useful.

But it also creates a subtle risk.

Once a dependency is injected, it can look acceptable simply because it is no longer constructed directly.

The code no longer says:

var emailSender = new SmtpEmailSender();

Instead, it says:

private readonly IEmailSender _emailSender;

That is usually better.

But it does not automatically mean the dependency belongs in that class.

The class may still know too much.

It may still coordinate too many concerns.

It may still depend on concepts from the wrong layer.

It may still mix workflow decisions, infrastructure behavior, validation, persistence, notification, logging, and presentation concerns.

DI has improved construction.

It has not necessarily improved responsibility.

For example:

public sealed class RegistrationService
{
    private readonly IUserRepository _userRepository;
    private readonly IPasswordHasher _passwordHasher;
    private readonly IEmailSender _emailSender;
    private readonly ITemplateRenderer _templateRenderer;
    private readonly IAnalyticsTracker _analyticsTracker;
    private readonly IWelcomeDiscountService _welcomeDiscountService;
    private readonly ILogger<RegistrationService> _logger;
    
    public RegistrationService(
        IUserRepository userRepository,
        IPasswordHasher passwordHasher,
        IEmailSender emailSender,
        ITemplateRenderer templateRenderer,
        IAnalyticsTracker analyticsTracker,
        IWelcomeDiscountService welcomeDiscountService,
        ILogger<RegistrationService> logger)
    {
        _userRepository = userRepository;
        _passwordHasher = passwordHasher;
        _emailSender = emailSender;
        _templateRenderer = templateRenderer;
        _analyticsTracker = analyticsTracker;
        _welcomeDiscountService = welcomeDiscountService;
        _logger = logger;
    }
}

This constructor is easy to justify one dependency at a time.

A registration flow needs to save the user.

It needs to hash the password.

It needs to send a welcome email.

It needs to render an email template.

It may need to track analytics.

It may need to apply a welcome discount.

It may need logging.

Each dependency has a reason to exist.

But together they raise a design question:

Is this service responsible for registration, or has it become responsible for everything that happens after registration?

The distinction matters.

Some of these dependencies may belong directly in the registration workflow.

Others may belong behind a more specific application-level concept.

For example, instead of the registration service knowing how to render and send a welcome email, it may depend on a more meaningful collaborator:

private readonly IWelcomeMessageSender _welcomeMessageSender;

That dependency still uses DI.

But it changes the design question.

The registration service no longer needs to know whether a welcome message is rendered from a template, sent by SMTP, sent through an API provider, queued for later delivery, or skipped in some environments.

It only knows that the registration workflow includes sending a welcome message.

The lower-level dependencies can move behind that boundary:

public sealed class WelcomeMessageSender : IWelcomeMessageSender
{
    private readonly ITemplateRenderer _templateRenderer;
    private readonly IEmailSender _emailSender;
    
    public WelcomeMessageSender(
        ITemplateRenderer templateRenderer,
        IEmailSender emailSender)
    {
        _templateRenderer = templateRenderer;
        _emailSender = emailSender;
    }
    
    public async Task SendAsync(
        RegisteredUser user,
        CancellationToken ct)
    {
        var message = await _templateRenderer.RenderAsync(
            "Welcome",
            user,
            ct);
            
        await _emailSender.SendAsync(message, ct);
    }
}

This is not automatically better in every case.

For a small application, the extra type may be unnecessary.

But the example shows the design issue clearly.

DI can make many low-level dependencies available everywhere.

Design decides whether a class should depend on those low-level details directly.

The same problem appears with repositories and clients.

A service may inject several repositories:

public sealed class ReportService
{
    private readonly ICustomerRepository _customerRepository;
    private readonly IOrderRepository _orderRepository;
    private readonly IInvoiceRepository _invoiceRepository;
    private readonly IPaymentRepository _paymentRepository;
}

That may be fine if the service genuinely builds a report from several data sources.

But it may also be a sign that the service is assembling a large amount of application knowledge from storage-shaped pieces.

A better design might introduce a query object, read model provider, or reporting-specific repository that answers the question the service actually has:

private readonly IRevenueReportDataProvider _revenueReportDataProvider;

Again, DI is still used.

But the dependency is now closer to the responsibility.

The service asks for revenue report data, not for four unrelated repositories that it must combine manually.

This is one of the ways DI can hide poor dependencies.

When everything is injectable, everything can feel available.

A class can gradually collect dependencies as new requirements arrive.

One feature needs a repository.

Another needs a client.

Another needs a clock.

Another needs a logger.

Another needs an email sender.

Another needs an options object.

Each addition is small.

Over time, the constructor becomes a map of responsibilities that have drifted into the same class.

The container still resolves it.

The tests can still mock it.

The code still follows the DI pattern.

But the design may be weakening.

Constructor injection is useful because it makes this visible.

A long constructor is not automatically wrong, but it is often honest.

It tells us that the class has many reasons to collaborate with the rest of the system.

That should trigger a design conversation, not only a refactoring to make the constructor shorter.

The goal is not to hide the dependencies behind a parameter object just to make the constructor look clean:

public sealed class RegistrationDependencies
{
    public IUserRepository UserRepository { get; init; } = default!;
    public IPasswordHasher PasswordHasher { get; init; } = default!;
    public IEmailSender EmailSender { get; init; } = default!;
    public ITemplateRenderer TemplateRenderer { get; init; } = default!;
    public IAnalyticsTracker AnalyticsTracker { get; init; } = default!;
    public ILogger Logger { get; init; } = default!;
}

That may reduce constructor noise, but it can also hide the signal.

The class still depends on the same set of collaborators.

Only now the dependencies are less explicit.

A poor dependency is not improved by being wrapped.

It is improved by deciding whether it belongs there.

Sometimes the right answer is to split the service.

Sometimes it is to introduce a meaningful collaborator.

Sometimes it is to move a decision into a domain object or policy.

Sometimes it is to move technical detail behind an infrastructure adapter.

Sometimes it is to keep the dependency exactly where it is, because the workflow really does need it.

The important part is the design judgment.

DI can also hide poor direction of dependency.

For example, an application service may depend on a web-specific abstraction:

private readonly ICurrentHttpRequest _currentHttpRequest;

The dependency may be injected through an interface.

But the concept still belongs to the web layer.

The interface does not erase the direction problem.

A better application-level abstraction might be:

private readonly ICurrentUser _currentUser;

The web layer can implement ICurrentUser using HTTP context, claims, cookies, headers, or another mechanism.

The application service receives the concept it needs.

It does not receive the delivery mechanism.

That is a design improvement.

The improvement is not caused by DI alone.

It is caused by choosing the right abstraction for the layer.

A useful question is:

Would this dependency still make sense if the current framework, provider, or delivery mechanism changed?

If the answer is no, the dependency may be too technical for the class receiving it.

Another useful question is:

Does this dependency describe what this class needs, or how another layer currently provides it?

A dependency named ICurrentUser describes an application need.

A dependency named IHttpContextAccessor describes a framework mechanism.

A dependency named IWelcomeMessageSender describes a workflow collaboration.

A dependency named SmtpEmailSenderOptions describes infrastructure configuration.

All of them may be valid somewhere.

They are not equally valid everywhere.

Dependency Injection can make all of them available.

Design decides where they belong.

That is why injected dependencies should not be accepted uncritically.

A constructor is not only setup code.

It is a design statement.

It says what the class needs in order to do its work.

When that list grows, or when the concepts come from the wrong layer, DI has given us a useful warning.

The warning should not be hidden.

It should be used.

3. Injecting an Interface Does Not Automatically Create a Boundary

Interfaces are often used together with Dependency Injection.

That makes sense.

An interface can describe what a class needs without tying it directly to a concrete implementation. It can make infrastructure replaceable. It can support tests. It can help keep object construction outside the class that uses the dependency.

Used well, interfaces are valuable.

But an interface does not automatically create a boundary.

It is possible to depend on an interface and still depend on the wrong concept.

For example:

public interface IArticleRepository
{
    Task<ArticleEntity?> GetByIdAsync(
        string articleId,
        CancellationToken ct);
        
    Task SaveAsync(
        ArticleEntity article,
        CancellationToken ct);
}

This interface may hide the concrete database implementation.

But it still exposes a persistence entity.

The caller may not know whether the implementation uses JSON files, SQL Server, SQLite, Entity Framework, Dapper, or an external API.

But the caller still depends on the persistence model.

The concrete implementation is hidden.

The persistence concept is not.

That distinction matters.

A boundary is not created only by replacing a class with an interface.

A boundary is created when the dependency protects responsibility, language, and direction.

For example, an application service may depend on this:

public interface IArticlePublishingRepository
{
    Task<Article?> GetEditableArticleAsync(
        string articleId,
        CancellationToken ct);
    
    Task SaveAsync(
        Article article,
        CancellationToken ct);
}

This interface still represents persistence access.

But it speaks more clearly in application terms.

The application service does not ask for a raw database entity.

It asks for an editable article.

The repository implementation may still load data from storage, map it, track it, and save it. Those are infrastructure concerns.

But the application dependency now describes what the use case needs, not only how the data happens to be stored.

That is closer to a boundary.

The same issue appears with framework abstractions.

For example:

public interface IRequestContext
{
    string? Header(string name);
    string? Cookie(string name);
    string? RouteValue(string name);
}

This may be an interface.

It may be easy to mock.

It may avoid a direct dependency on HttpContext.

But it still exposes web request concepts.

If this interface is used inside the web layer, that may be fine.

If it is used deep inside the application layer, the application code is still shaped by the delivery mechanism.

The interface has hidden the framework type.

It has not translated the framework concept.

A better application-level dependency might be:

public interface ICurrentUser
{
    string UserId { get; }
    bool IsAuthenticated { get; }
}

This interface describes what the application needs.

The web layer can implement it using HTTP context, claims, cookies, headers, or another mechanism.

The application layer does not need to know how the user was identified.

That is a stronger boundary.

The difference is not that one interface is better because it is smaller or easier to mock.

The difference is that one interface exposes a delivery mechanism, while the other exposes an application concept.

Interfaces can also create the illusion of abstraction when they simply mirror an implementation.

For example:

public interface IEmailSender
{
    Task SendSmtpMessageAsync(
        SmtpMessage message,
        CancellationToken ct);
}

This interface hides the concrete sender class.

But the method still speaks SMTP language.

That may be appropriate inside an SMTP adapter.

It is less appropriate if the application service only wants to send a welcome message, confirmation email, or notification.

A more useful application-facing interface might be:

public interface IWelcomeMessageSender
{
    Task SendAsync(
        RegisteredUser user,
        CancellationToken ct);
}

or:

public interface IConfirmationEmailSender
{
    Task SendAsync(
        ConfirmationEmailRequest request,
        CancellationToken ct);
}

These interfaces are less generic.

But they protect more meaning.

They keep SMTP details, template rendering, provider-specific options, retry behavior, and message construction away from the workflow that only needs the message to be sent.

That is the important design question.

Not:

Is this dependency an interface?

But:

What concept does this interface expose?

An interface that exposes the wrong concept can still create coupling.

A class can depend on IHttpContextAccessor, IQueryableProvider, IDbConnectionFactory, ISmtpClient, IFileSystem, or IOptions<SomeProviderOptions> through DI.

Those dependencies may be valid in infrastructure or adapter code.

But when they appear in application services, they may show that technical mechanisms have crossed the boundary.

The interface has made the dependency substitutable.

It has not necessarily made it appropriate.

Testing can hide this problem as well.

If an interface is introduced only so a dependency can be mocked, it may not represent a real design boundary.

For example:

public interface IArticleService
{
    Task ProcessAsync(
        ArticleInput input,
        CancellationToken ct);
}

If there is only one implementation, no meaningful abstraction, and no clearer language than the concrete class already had, the interface may not add much value.

It may only make tests easier to wire.

That can be useful in some cases.

But being easy to mock should not be confused with good design.

A mockable dependency can still be the wrong dependency.

A test can replace an interface with a fake and still be coupled to poor boundaries, vague operations, or technical language.

A useful interface usually does at least one of these things:

  • protects a boundary between layers,
  • represents an external system or provider,
  • describes a stable application need,
  • hides a technical mechanism behind application language,
  • allows meaningful variation between implementations,
  • or separates a policy from the code that uses it.

If an interface does none of those things, it may be ceremony.

That does not mean it must always be removed.

Some teams prefer interfaces for consistency. Some frameworks or libraries encourage them. Some architectures use them to enforce dependency direction. Some interfaces are introduced early because a variation point is expected soon.

Those reasons may be valid.

But they should be recognized as trade-offs.

An interface should not be assumed to improve design simply because it exists.

The name of the interface is often a clue.

IArticlePublishingPolicy suggests a decision.

IClock suggests an external source of time.

IEmailProvider suggests an external mechanism.

ILicenseRestoreService suggests an application operation.

IHttpRequestReader suggests a delivery concern.

IArticleRepository may suggest persistence, but its methods and return types decide whether it speaks application language or storage language.

The boundary is not in the I.

The boundary is in the responsibility the interface protects.2

A useful question is:

If this interface had only one implementation forever, would it still clarify the design?

If the answer is yes, the interface may represent a meaningful boundary or concept.

If the answer is no, it may exist mainly for substitution or testing.

That can still be useful.

But it is not the same thing as design clarity.

Another useful question is:

Does this interface hide a concrete class, or does it translate a concept?

Hiding a class can reduce direct coupling.

Translating a concept can protect a boundary.

Those are related, but they are not the same.

Dependency Injection works well with interfaces.

But DI and interfaces together are still only mechanisms.

They can help express a design.

They cannot replace the responsibility decisions that make the design meaningful.

4. Service Registration Is Not Architecture

Dependency Injection containers need registration.

Somewhere, the application must describe which concrete implementations should be used for which abstractions. It must decide which services are singletons, scoped, or transient. It must configure options, adapters, clients, repositories, handlers, background services, validators, and infrastructure components.

That registration is important.

Without it, the application cannot be assembled.

But service registration is not the same as architecture.

A startup file or composition root can show how pieces are wired together. It can show which implementation satisfies which interface. It can show lifetimes, configuration sources, and provider choices.

But it does not automatically explain why the pieces exist, which responsibilities they protect, or whether the boundaries are meaningful.

For example:

services.AddScoped<IArticleRepository, ArticleRepository>();
services.AddScoped<IArticlePublishingService, ArticlePublishingService>();
services.AddScoped<IEmailSender, SmtpEmailSender>();
services.AddScoped<IAnalyticsTracker, AnalyticsTracker>();
services.AddScoped<ICurrentUser, HttpCurrentUser>();

This registration may be perfectly reasonable.

It tells the container how to build the graph.

But it does not answer the design questions.

  • Should article publishing depend directly on email sending?
  • Should analytics be part of the publishing workflow or handled after the fact?
  • Does IArticleRepository expose application-level methods or persistence-shaped operations?
  • Does ICurrentUser protect the application layer from HTTP details, or does it only rename them?
  • Are these services grouped around clear responsibilities, or are they just the classes that happened to exist?

The container cannot answer those questions.

It can only assemble what it has been given.

This is why a well-organized registration file can still hide a poorly organized design.

The code may look clean because everything is registered in one place:

public static IServiceCollection AddApplicationServices(
    this IServiceCollection services)
{
    services.AddScoped<IArticleService, ArticleService>();
    services.AddScoped<ILicenseService, LicenseService>();
    services.AddScoped<IFeedbackService, FeedbackService>();
    services.AddScoped<IReportService, ReportService>();
    
    return services;
}

This can be useful as an organizational step.

It keeps registrations near the layer or feature they belong to.

It reduces clutter in application startup.

It can make composition easier to maintain.

But the method name AddApplicationServices does not prove that the registered services express application behavior.

A service named ArticleService may still be a procedural collection of unrelated article operations.

A service named LicenseService may still mix activation, validation, restore, purchase fulfillment, and device management in one class.

A service named ReportService may still depend on many repositories and build storage-shaped results.

The registration may be tidy.

The responsibilities may still be unclear.

Architecture is not defined by the number of extension methods used to register services.

It is defined by the decisions those services represent.

A common mistake is to treat the DI container as the system map.

Developers open the registration code to understand the design. They see many interfaces and implementations, and the structure appears deliberate:

services.AddScoped<IOrderService, OrderService>();
services.AddScoped<IOrderValidator, OrderValidator>();
services.AddScoped<IOrderProcessor, OrderProcessor>();
services.AddScoped<IOrderNotifier, OrderNotifier>();
services.AddScoped<IOrderRepository, OrderRepository>();

This may be a good design.

Or it may be an anemic chain of services that pass data from one procedural step to another.

The registration alone cannot tell us.

The real question is what each service owns.

  • Does IOrderValidator express a rule that belongs outside the order itself, or is it only a collection of checks that should be closer to the model?
  • Does IOrderProcessor describe a use case, or is it a vague coordinator?
  • Does IOrderNotifier protect the workflow from notification details, or does it expose email-specific concerns?
  • Does IOrderRepository answer application-level questions, or does it expose database-shaped access?

Those are architecture questions.

They are not registration questions.

Service lifetimes can create another illusion.

A service may be registered as scoped, singleton, or transient, and those choices matter technically. The wrong lifetime can cause serious bugs. A singleton should not depend on scoped services. A scoped service may be appropriate for request-specific work. A transient service may be fine for lightweight stateless operations.

But lifetime choices describe object management.

They do not define application responsibility.

For example:

services.AddScoped<IArticlePublishingService, ArticlePublishingService>();

This says that one instance of ArticlePublishingService should be used within a scope.

  • It does not say whether publishing is modeled well.
  • It does not say whether the service owns the right decisions.
  • It does not say whether the service depends on the right abstractions.
  • It only says how the object should be created and reused.

That is useful.

It is not design by itself.

Options registration has the same limitation.

For example:

services.Configure<SmtpOptions>(
    configuration.GetSection("Smtp"));

This may be necessary infrastructure setup.

But if application services begin to depend directly on SmtpOptions, SMTP provider configuration has moved too far into the application.

The registration is not the problem.

The dependency direction is.

A composition root should know about technical wiring.

Application services should usually know about application needs.

Those are different responsibilities.

Registration code can also make it too easy to add dependencies without revisiting design.

A feature needs something new, so another service is registered.

Another provider is added.

Another adapter is introduced.

Another options class is configured.

Another decorator is inserted.

That may be the right change.

But the registration step can feel mechanical enough that the design question is skipped.

The real question should be:

What responsibility does this new service represent?

If the answer is clear, registration supports the design.

If the answer is vague, registration may be hiding design drift.

A healthy composition root should be boring.

  • It should assemble the system.
  • It should keep construction, configuration, and provider choices near the application boundary.
  • It should not become the place where application behavior is understood.

If the only way to understand a workflow is to inspect how a chain of services is registered, the design may be too container-driven.

For example, a pipeline like this may be technically elegant:

services.AddScoped<IOrderStep, ValidateOrderStep>();
services.AddScoped<IOrderStep, ReserveInventoryStep>();
services.AddScoped<IOrderStep, CapturePaymentStep>();
services.AddScoped<IOrderStep, SendConfirmationStep>();

This may be appropriate for some workflows.

But it should still be clear in application language what the workflow is, what each step owns, what happens on failure, and which outcomes matter.

The registration should not be the only place where the workflow can be seen.

Container features can be powerful.

Decorators, open generics, scanning, keyed services, factories, options, pipelines, and conditional registrations can reduce repetitive code. They can make cross-cutting concerns easier to apply. They can help large systems stay manageable.

But the more behavior is hidden in container configuration, the more important it becomes to keep the design understandable outside the container.

A developer should be able to read the application service, policy, handler, or workflow and understand the important decisions without mentally executing the DI registration process.

A useful question is:

Does the registration support the architecture, or is the registration the architecture?

If the design is clear before looking at the container, the container is probably doing its job.

If the design only becomes visible through registration chains, decorators, factories, and service scanning, the container may be carrying too much meaning.

Another useful question is:

Would these responsibilities still make sense if they were constructed manually?

This question helps separate design from mechanism.

If the answer is yes, DI is probably supporting a meaningful structure.

If the answer is no, the structure may be too dependent on container behavior.

Service registration should be treated as composition, not as proof of design.

A clean registration file is good.

A clear dependency graph is useful.

Correct lifetimes matter.

But architecture still comes from deciding what each part is responsible for, which concepts belong where, and which boundaries should be protected.

The DI container can assemble those decisions.

It cannot make them for us.

5. Too Many Dependencies Often Signal Unclear Responsibility

A long constructor is not automatically a design problem.

Some classes really do coordinate several collaborators. A workflow may need persistence, authorization, time, notifications, logging, and an external provider. A background process may need multiple services to complete its work. A composition component may legitimately depend on several smaller parts.

So the number of dependencies alone does not prove that a class is poorly designed.

But it is often a useful signal.

A constructor shows what a class needs in order to do its work. When that list grows, the class is telling us something. It may be coordinating a complex use case. It may be acting as a façade over several smaller operations. It may be collecting unrelated responsibilities. It may be compensating for missing domain concepts, missing policies, or missing workflow boundaries.

Dependency Injection makes that signal visible.

For example:

public sealed class LicenseService
{
    private readonly ILicenseRepository _licenseRepository;
    private readonly ICustomerRepository _customerRepository;
    private readonly IDeviceRepository _deviceRepository;
    private readonly IPaymentRepository _paymentRepository;
    private readonly IEmailSender _emailSender;
    private readonly IClock _clock;
    private readonly ILogger<LicenseService> _logger;
    
    public LicenseService(
        ILicenseRepository licenseRepository,
        ICustomerRepository customerRepository,
        IDeviceRepository deviceRepository,
        IPaymentRepository paymentRepository,
        IEmailSender emailSender,
        IClock clock,
        ILogger<LicenseService> logger)
    {
        _licenseRepository = licenseRepository;
        _customerRepository = customerRepository;
        _deviceRepository = deviceRepository;
        _paymentRepository = paymentRepository;
        _emailSender = emailSender;
        _clock = clock;
        _logger = logger;
    }
}

This constructor may be justified.

But it should raise questions.

What does LicenseService actually do?

  • Does it activate licenses?
  • Validate licenses?
  • Restore licenses?
  • Create licenses after purchase?
  • Manage devices?
  • Send customer emails?
  • Record payments?
  • Clean up expired licenses?

If the answer is “all of the above”, the service may have become a broad procedural container for everything related to licenses.

That is not a DI problem.

DI only made the problem visible.

The design problem is that one class may have too many reasons to change.

  • A payment change affects it.
  • A device activation change affects it.
  • A restore workflow change affects it.
  • A customer email change affects it.
  • A validation rule change affects it.
  • A reporting requirement may affect it.

Those are different responsibilities, even if they all involve licenses.

A clearer design may separate the workflows:

public sealed class LicenseActivationService
{
    private readonly ILicenseRepository _licenseRepository;
    private readonly IDeviceRepository _deviceRepository;
    private readonly IClock _clock;
    
    public LicenseActivationService(
        ILicenseRepository licenseRepository,
        IDeviceRepository deviceRepository,
        IClock clock)
    {
        _licenseRepository = licenseRepository;
        _deviceRepository = deviceRepository;
        _clock = clock;
    }
}

public sealed class LicenseRestoreService
{
    private readonly ILicenseRepository _licenseRepository;
    private readonly ICustomerRepository _customerRepository;
    private readonly IEmailSender _emailSender;
    
    public LicenseRestoreService(
        ILicenseRepository licenseRepository,
        ICustomerRepository customerRepository,
        IEmailSender emailSender)
    {
        _licenseRepository = licenseRepository;
        _customerRepository = customerRepository;
        _emailSender = emailSender;
    }
}

public sealed class PurchaseFulfillmentService
{
    private readonly IPaymentRepository _paymentRepository;
    private readonly ILicenseRepository _licenseRepository;
    private readonly IEmailSender _emailSender;
    
    public PurchaseFulfillmentService(
        IPaymentRepository paymentRepository,
        ILicenseRepository licenseRepository,
        IEmailSender emailSender)
    {
        _paymentRepository = paymentRepository;
        _licenseRepository = licenseRepository;
        _emailSender = emailSender;
    }
}

This is not better because the constructors are shorter.

It is better only if the responsibilities are clearer.

  • Each service now has a more specific reason to exist.
  • Each service can be tested around a more focused workflow.
  • Each service can change for a narrower set of reasons.
  • Each dependency is easier to justify because it belongs to a named operation.

That is the important point.

Shorter constructors are a side effect of clearer responsibility, not the goal.

It is possible to reduce constructor size in a way that makes the design worse.

For example:

public sealed class LicenseServiceDependencies
{
    public ILicenseRepository LicenseRepository { get; init; } = default!;
    public ICustomerRepository CustomerRepository { get; init; } = default!;
    public IDeviceRepository DeviceRepository { get; init; } = default!;
    public IPaymentRepository PaymentRepository { get; init; } = default!;
    public IEmailSender EmailSender { get; init; } = default!;
    public IClock Clock { get; init; } = default!;
    public ILogger<LicenseService> Logger { get; init; } = default!;
}

Then the service can depend on only one object:

public sealed class LicenseService
{
    private readonly LicenseServiceDependencies _dependencies;
    
    public LicenseService(
        LicenseServiceDependencies dependencies)
    {
        _dependencies = dependencies;
    }
}

The constructor now looks small.

But the design has not improved.

The same dependencies are still there. The same responsibilities may still be mixed. The only difference is that the signal has been hidden inside another object.

That can make the code harder to understand.

It can also make the class easier to misuse, because the dependency object may give access to many collaborators that each method does not really need.

A better response to a long constructor is not always “wrap the dependencies”.

A better response is usually “understand why the dependencies are there”.

Some dependencies indicate technical needs.

  • A clock may provide time.
  • A logger may record diagnostics.
  • An options object may provide configuration.
  • A repository may provide persistence.
  • An email sender may adapt an external provider.

Those dependencies may be appropriate.

But the mix of dependencies can reveal the class’s actual role.

If a service depends on several repositories, it may be coordinating data from many sources.

If it depends on a repository, an email sender, a template renderer, an analytics tracker, and a payment client, it may be coordinating a broad workflow.

If it depends on HTTP context, database access, UI formatting, and domain services, it may be crossing too many boundaries.

If it depends on many validators, calculators, policies, and helper classes, it may be missing a clearer domain concept.

The constructor is evidence.

It should be read as part of the design.

A useful question is:

Do all of these dependencies change for the same reason?

If the answer is no, the class may be holding more than one responsibility.

Another useful question is:

Would the name of this class still make sense if one of these dependencies disappeared?

If removing an email sender changes the meaning of a license validation service, perhaps the service is not only validating licenses.

If removing a payment repository changes the meaning of a license activation service, perhaps activation and purchase fulfillment are being mixed.

If removing a UI formatter changes an application service, perhaps presentation responsibility has leaked inward.

A third useful question is:

Are these dependencies collaborators in one workflow, or tools for several unrelated workflows?

That distinction matters.

A workflow can legitimately have several steps.

But a service that contains many workflows often grows dependencies because each workflow brings its own needs.

For example:

public sealed class ArticleService
{
    private readonly IArticleRepository _articleRepository;
    private readonly IMarkdownRenderer _markdownRenderer;
    private readonly ISlugGenerator _slugGenerator;
    private readonly INewsletterSender _newsletterSender;
    private readonly IImageStore _imageStore;
    private readonly IAnalyticsTracker _analyticsTracker;
}

This service might be responsible for creating articles, rendering previews, generating slugs, publishing, sending newsletters, storing images, and tracking analytics.

Those concerns are related by topic.

They are not necessarily the same responsibility.

A more focused design may separate them into services named around operations:

ArticleDraftService
ArticlePreviewService
ArticlePublishingService
ArticleImageService
NewsletterAnnouncementService

Those names may not be perfect.

The point is not the exact names.

The point is that each service should be shaped by a responsibility, not only by a noun such as Article.

Large noun-based services often attract dependencies because many operations fit under the same noun.

UserService, OrderService, LicenseService, ArticleService, and ReportService can become magnets for unrelated behavior.

Dependency Injection does not cause that problem.

But it can make it easier for the problem to grow gradually.

  • A new dependency is added.
  • A new method uses it.
  • Another feature adds another dependency.
  • A later feature reuses the service because it already has access to related data.

Over time, the service becomes central, not because it represents a good boundary, but because it is convenient.

That kind of convenience is expensive.

  • It makes tests larger.
  • It makes changes riskier.
  • It makes constructors noisier.
  • It makes dependencies harder to reason about.
  • It makes the service harder to split later.

A long constructor should therefore be treated as a design conversation.

Not a rule violation.

Not an automatic refactoring target.

A conversation.

Sometimes the conclusion will be that the dependencies belong together.

Sometimes the conclusion will be that one dependency should move behind a more meaningful collaborator.

Sometimes the conclusion will be that a service should be split by workflow.

Sometimes the conclusion will be that a domain concept should own more of the rule.

Sometimes the conclusion will be that the code is fine for now, but should be watched.

A useful practical step is to group dependencies by method.

If only one method uses _emailSender, ask whether email sending belongs directly in this service or behind a workflow-specific collaborator.

If only one method uses _paymentRepository, ask whether purchase fulfillment should be separated from validation.

If every method uses _articleRepository, that dependency probably belongs.

If different groups of methods use different groups of dependencies, the class may contain several responsibilities.

This is a simple way to let the code explain its own shape.

Dependency Injection makes dependencies explicit.

That is one of its strengths.

But explicit dependencies are only helpful if we pay attention to what they reveal.

A long constructor is often not the disease.

It is a symptom.

The design question is what responsibility has grown large enough to need all those collaborators.

6. DI Can Encourage Procedural Service Chains

Dependency Injection makes it easy to connect services.

That is one of its strengths.

A class can receive a collaborator through its constructor, call it, and let the container handle the details of creating the object graph. That keeps construction out of the class and allows each component to depend on abstractions rather than concrete implementations.

But this convenience can also lead to a particular style of design.

A workflow is split into many services.

Each service performs one procedural step.

Each step calls the next service.

The result is a chain of injected dependencies where behavior moves from object to object, but responsibility is not always clearer.

For example:

public sealed class OrderProcessor
{
    private readonly IOrderValidator _orderValidator;
    private readonly IInventoryReserver _inventoryReserver;
    private readonly IPaymentCapturer _paymentCapturer;
    private readonly IOrderNotifier _orderNotifier;
    
    public OrderProcessor(
        IOrderValidator orderValidator,
        IInventoryReserver inventoryReserver,
        IPaymentCapturer paymentCapturer,
        IOrderNotifier orderNotifier)
    {
        _orderValidator = orderValidator;
        _inventoryReserver = inventoryReserver;
        _paymentCapturer = paymentCapturer;
        _orderNotifier = orderNotifier;
    }
    
    public async Task<ProcessOrderResult> ProcessAsync(
        ProcessOrderRequest request,
        CancellationToken ct)
    {
        await _orderValidator.ValidateAsync(request, ct);
        await _inventoryReserver.ReserveAsync(request, ct);
        await _paymentCapturer.CaptureAsync(request, ct);
        await _orderNotifier.SendConfirmationAsync(request, ct);
        return ProcessOrderResult.Succeeded();
    }
}

This may be a reasonable design.

Each dependency may represent a real responsibility. Validation, inventory reservation, payment capture, and notification may all involve different systems, different rules, and different failure modes.

But the structure should still be questioned.

  • Does each service own a meaningful decision?
  • Or is each one only a procedural step extracted into a separate class?

If each dependency simply receives the same request, performs a small action, and passes control back, the design may be organized but not very expressive.

It can become a distributed procedure.

The workflow is no longer in one method, but it is still procedural. The logic has been spread across several injected services, and the main class mostly coordinates calls.

That may be fine for some orchestration code.

But it should not be mistaken for deeper design.

For example:

await _stepOne.ExecuteAsync(context, ct);
await _stepTwo.ExecuteAsync(context, ct);
await _stepThree.ExecuteAsync(context, ct);
await _stepFour.ExecuteAsync(context, ct);

This kind of code can look flexible.

It may even be registered elegantly in the DI container.

But the important question is still:

What does each step mean?

If the answer is only “it is the next thing in the process”, the services may not represent meaningful boundaries.

They may only represent fragments of a procedure.

This often happens when design is driven by verbs instead of responsibilities.

A system may accumulate services named:

OrderValidator
OrderProcessor
OrderHandler
OrderManager
OrderUpdater
OrderNotifier
OrderFinalizer

Some of these may be useful.

But the names can also become vague. They describe activity, but not always ownership. They can make it hard to see where the real decision belongs.

For example, who decides whether an order can be accepted?

  • The validator?
  • The processor?
  • The payment capturer?
  • The inventory reserver?
  • The order itself?
  • A policy?
  • A workflow service?

If the decision is spread across several injected services, the architecture may have many components but no clear owner.

Dependency Injection can make that easy to tolerate because each component is easy to add and easy to call.

A new rule appears, so a new service is introduced.

A new step appears, so another dependency is injected.

A new provider appears, so another adapter is registered.

Each change feels local.

But the workflow may become harder to understand as a whole.

The opposite problem can also happen.

A single application service may become a procedural script that calls many injected helpers:

public async Task<PublishArticleResult> PublishAsync(
    PublishArticleRequest request,
    CancellationToken ct)
{
    var article = await _articleRepository.GetByIdAsync(
        request.ArticleId,
        ct);
        
    await _articleValidator.ValidateForPublishingAsync(
        article,
        ct);
        
    var renderedContent = await _markdownRenderer.RenderAsync(
        article.ContentMarkdown,
        ct);
        
    await _articleRepository.SaveAsync(
        article,
        ct);
        
    await _newsletterSender.SendAsync(
        article,
        renderedContent,
        ct);
        
    await _analyticsTracker.TrackAsync(
        "ArticlePublished",
        article.Id,
        ct);
        
    return PublishArticleResult.Succeeded();
}

Again, this may be acceptable.

Publishing may really include several steps.

But the method should make clear which parts are application decisions and which parts are technical consequences.

If validation, rendering, persistence, notification, and analytics are all treated as equal procedural calls, the workflow may become harder to reason about.

Some steps may belong inside the publishing decision.

Some may belong after the article has been published.

Some may be infrastructure effects.

Some may be optional side effects.

Some may need compensation if later steps fail.

A chain of injected services does not answer those questions.

It only makes the steps callable.

A stronger design may separate the core decision from consequences:

public async Task<PublishArticleResult> PublishAsync(
    PublishArticleRequest request,
    CancellationToken ct)
{
    var article = await _articleRepository.GetEditableArticleAsync(
        request.ArticleId,
        ct);
        
    if (article is null)
    {
        return PublishArticleResult.NotFound();
    }
    
    if (!article.CanBePublished())
    {
        return PublishArticleResult.NotReady();
    }
    
    article.Publish(request.PublishedAt);
    
    await _articleRepository.SaveAsync(article, ct);
    
    await _articlePublishedEvents.PublishAsync(
        new ArticlePublished(article.Id),
        ct);
        
    return PublishArticleResult.Succeeded();
}

This version still uses DI.

It still coordinates work.

But it makes the publishing decision clearer.

The service loads the editable article, checks whether it can be published, changes its state, saves it, and publishes an application event. Notification, analytics, indexing, or other consequences can react to that event elsewhere.

That is not always necessary.

For a small system, direct calls may be simpler.

But the design distinction is important.

A procedural chain says:

Do this, then this, then this.

A clearer workflow says:

Make this application decision, then handle the consequences.

Dependency Injection can support either style.

It does not choose between them.

Procedural service chains also affect tests.

A test may need to mock every step in the chain:

var validator = new MockOrderValidator();
var reserver = new MockInventoryReserver();
var capturer = new MockPaymentCapturer();
var notifier = new MockOrderNotifier();
var processor = new OrderProcessor(
    validator,
    reserver,
    capturer,
    notifier);

The test may then verify that each service was called in the expected order.

That can be useful for orchestration.

But if most tests only verify that one service called the next service, the design may not have enough behavior at the level being tested.

The tests may be protecting the procedure rather than the application meaning.

A more behavior-focused test might assert the result of the workflow:

var result = await processor.ProcessAsync(
    request,
    CancellationToken.None);
    
Assert.Equal(
    ProcessOrderStatus.InventoryUnavailable,
    result.Status);

That kind of test asks what the workflow means, not only which collaborator was called.

Good design usually needs both kinds of thinking.

Some orchestration must happen.

Some side effects must be ordered.

Some integrations must be called.

But the important decisions should still be visible in application language.

Another warning sign is when every service has the same shape:

Task HandleAsync(Context context, CancellationToken ct);

A shared shape can be useful for pipelines.

But if all behavior is expressed through generic handlers and a mutable context, the application language may disappear.

The container may know which handlers are registered.

The pipeline may know which order they run in.

But a developer may need to inspect many small classes to understand one business operation.

That can be a real cost.

A useful question is:

Is this chain expressing a workflow, or only distributing a procedure?

If the chain expresses a workflow, each step should have a clear reason to exist, a clear responsibility, and meaningful outcomes.

If it only distributes a procedure, the design may have more moving parts without more clarity.

Another useful question is:

Where is the application decision made?

If the decision is visible in one place, the chain may be supporting the design.

If the decision is scattered across many services, the chain may be hiding the design.

Dependency Injection makes it easy to connect procedural pieces.

That does not mean every piece should become a service.

Sometimes a private method is enough.

Sometimes a domain method is clearer.

Sometimes a policy object is useful.

Sometimes an application event separates consequences from decisions.

Sometimes a dedicated workflow service is the right place to coordinate.

The point is not to avoid service chains entirely.

The point is to avoid mistaking service chains for design.

DI can wire a sequence of calls.

Design must decide what the sequence means.

7. Lifetime Management Is a Technical Concern, Not a Design Model

Dependency Injection containers usually manage object lifetimes.

A service can be registered as transient, scoped, or singleton. A transient service is created when needed. A scoped service is reused within a defined scope, such as a web request. A singleton service is created once and reused for the lifetime of the application.

Those choices matter.

Incorrect lifetime management can create real bugs. A singleton can accidentally capture scoped state. A scoped service can hold request-specific data longer than intended. A transient service can be created too often if construction is expensive. A service with mutable state can behave unpredictably if it is shared in the wrong way.

So lifetime management is important.

But lifetime management is not a design model.

A service does not become well designed because it has the correct lifetime.

A class does not become an application concept because it is registered as scoped.

A component does not become infrastructure because it is registered as singleton.

The lifetime tells the container how long an object should live.

It does not tell the application what responsibility that object should have.

For example:

services.AddScoped<IArticlePublishingService, ArticlePublishingService>();
services.AddScoped<IArticleRepository, ArticleRepository>();
services.AddSingleton<IClock, SystemClock>();
services.AddTransient<IEmailMessageBuilder, EmailMessageBuilder>();

These registrations may be technically correct.

The publishing service and repository may be scoped because they participate in request-level work.

The clock may be singleton because it has no request-specific state.

The message builder may be transient because it is lightweight.

But none of that proves that the publishing workflow is modeled well.

The registration does not answer whether ArticlePublishingService owns the right decisions, whether IArticleRepository exposes the right language, whether IEmailMessageBuilder belongs in the application layer, or whether publishing should directly send emails at all.

Those are design questions.

The container only manages lifetime.

This distinction is easy to miss because lifetimes can feel architectural.

They are configured centrally. They affect many parts of the system. They influence dependency direction and runtime behavior. They can cause subtle problems if chosen poorly.

But they are still technical concerns.

They describe object management, not responsibility.

For example, a repository may be scoped because it uses a scoped database context:

services.AddScoped<IArticleRepository, ArticleRepository>();

That registration may be necessary.

But the repository interface still needs design attention.

  • Does it expose IQueryable?
  • Does it return persistence entities?
  • Does it answer application-level questions?
  • Does it translate expected storage failures?
  • Does it keep database concerns behind the persistence boundary?

The lifetime does not answer any of that.

A singleton service can also be well designed or poorly designed.

For example:

services.AddSingleton<IEmailTemplateCatalog, EmailTemplateCatalog>();

This may be fine if the catalog is immutable, thread-safe, and only provides template definitions.

But if a singleton begins to hold mutable workflow state, cache user-specific decisions, or depend indirectly on request-specific information, the problem is not only lifetime configuration. The problem is that the component’s responsibility is unclear.

The same service may look technically correct in the container and still be conceptually wrong.

Lifetime rules can also distort design when developers shape the model around the container instead of the application.

For example, a class may be made stateless only because it is easier to register as singleton.

Or a service may avoid holding useful state because shared instances feel dangerous.

Or workflow state may be placed into a generic context object because the service itself is transient.

Or request-specific information may be accessed through a service locator because constructor injection creates lifetime conflicts.

Those choices may solve immediate technical problems.

But they can also move the design away from the application model.

The question should not begin with:

What lifetime can this class have?

It should begin with:

What responsibility does this class have?

After that, the lifetime can be chosen to support the responsibility.

For example, an application service that coordinates a use case may usually be stateless and scoped or transient.

A repository that uses a database context may usually share the context lifetime.

A provider client may be singleton if it is thread-safe and designed for reuse.

A domain object may not be registered in the container at all.

A workflow state object may be created directly as part of the use case rather than registered as a service.

The design determines the role.

The lifetime supports the role.

Problems appear when that relationship is reversed.

For example, consider a service that needs request-specific information:

public sealed class ArticlePublishingService
{
    private readonly IHttpContextAccessor _httpContextAccessor;
    
    public ArticlePublishingService(
        IHttpContextAccessor httpContextAccessor)
    {
        _httpContextAccessor = httpContextAccessor;
    }
}

This may solve a practical lifetime issue.

IHttpContextAccessor can be injected, and the service can read the current user, request headers, or route values when needed.

But the design question remains.

Should the application service know about HTTP context?

Probably not.

A better design may pass an application-level concept into the use case:

public sealed record PublishArticleRequest(
    string ArticleId,
    string UserId,
    DateTimeOffset PublishedAt);

The web layer can extract UserId from HTTP context and create the request.

The application service receives the information it needs without depending on the delivery mechanism.

This is not primarily a lifetime fix.

It is a boundary fix.

The lifetime issue may disappear as a consequence, but the real improvement is that the application service no longer depends on HTTP concepts.

Lifetime management can also hide service locator patterns.

For example:

public sealed class ReportRunner
{
    private readonly IServiceProvider _serviceProvider;
    
    public ReportRunner(IServiceProvider serviceProvider)
    {
        _serviceProvider = serviceProvider;
    }
    
    public async Task RunAsync(CancellationToken ct)
    {
        using var scope = _serviceProvider.CreateScope();
        var reportService = scope.ServiceProvider
                                 .GetRequiredService<IReportService>();

        await reportService.GenerateAsync(ct);
    }
}

Sometimes this pattern is necessary, especially in background services that need to create scopes.

But it should be used deliberately.

If many services start resolving dependencies manually, the dependency graph becomes harder to see. Constructor injection no longer tells the truth about what a class needs. The container becomes part of the control flow.

Again, the issue is not only technical.

It affects design clarity.

The more a class reaches into the container at runtime, the less visible its responsibilities become.

That does not mean IServiceProvider should never be used.

It means it should usually stay near composition, hosting, background-service boundaries, factories, or integration points where scope creation is genuinely part of the job.

Application services should usually receive the dependencies they need directly.

That keeps the design visible.

A useful question is:

Is this lifetime choice supporting the design, or is the design being shaped around the lifetime?

If the lifetime supports the design, the dependency structure will usually still make sense without the container.

If the design is shaped around the lifetime, the code may contain service locators, awkward stateless services, hidden context objects, or dependencies on framework-specific lifetime mechanisms.

Another useful question is:

Does this object represent application responsibility, or container management?

Some objects exist mainly to help the container assemble and manage the system.

Factories, hosted services, registration extensions, adapter setup, options configuration, and scope creation code often belong near composition and infrastructure.

Other objects express application behavior.

Use cases, policies, commands, results, and domain concepts should usually be understandable without knowing their DI lifetime.

Keeping those roles separate makes the design clearer.

Lifetime management is necessary.

But it should remain a supporting mechanism.

  • It can prevent runtime bugs.
  • It can improve performance.
  • It can keep scoped resources safe.
  • It can make infrastructure clients reusable.

But it cannot tell us which responsibilities belong together, which concepts should cross a boundary, or which dependencies are appropriate for a class.

A correct lifetime can make a poor design run reliably.

It does not make the design good.

DI lifetimes should serve the architecture.

They should not become the architecture.3

8. Testability Requires More Than Mockable Constructors

Dependency Injection often improves testability.

When a class receives its dependencies through its constructor, a test can replace those dependencies with fakes, stubs, or mocks. The class can be tested without creating real databases, sending real emails, calling real payment providers, or depending on the full application startup process.

That is useful.

It is one of the main practical reasons DI became so common.

But testability is not the same as being easy to mock.

A class can be easy to construct in a test and still be difficult to test well.

For example:

public sealed class OrderService
{
    private readonly IOrderRepository _orderRepository;
    private readonly IPaymentGateway _paymentGateway;
    private readonly IInventoryClient _inventoryClient;
    private readonly IEmailSender _emailSender;
    private readonly ILogger<OrderService> _logger;
    
    public OrderService(
        IOrderRepository orderRepository,
        IPaymentGateway paymentGateway,
        IInventoryClient inventoryClient,
        IEmailSender emailSender,
        ILogger<OrderService> logger)
    {
        _orderRepository = orderRepository;
        _paymentGateway = paymentGateway;
        _inventoryClient = inventoryClient;
        _emailSender = emailSender;
        _logger = logger;
    }
}

This class is mockable.

A test can create mocks for all five dependencies and pass them into the constructor.

But that does not automatically make the design testable in a meaningful way.

If each test needs to prepare many mocks, set up many expected calls, and verify a long sequence of interactions, the test may be telling us that the service has too much responsibility or that the behavior is too procedural.

The test can build the class.

But it may still struggle to explain the behavior.

That distinction matters.

A mockable constructor helps with setup.

Good testability helps with understanding.

A test should ideally show what behavior matters:

[Fact]
public async Task PlaceOrderAsync_ReturnsPaymentFailed_WhenPaymentIsRejected()
{
    var orders = new FakeOrderRepository();
    var payments = new FakePaymentGateway
    {
        NextResult = PaymentResult.Rejected()
    };
    
    var service = new OrderPlacementService(
        orders,
        payments,
        new FakeInventoryClient(),
        new FakeEmailSender());
        
    var result = await service.PlaceOrderAsync(
        new PlaceOrderRequest("customer-1", "cart-1"),
        CancellationToken.None);
        
    Assert.Equal(
        PlaceOrderStatus.PaymentFailed,
        result.Status);
}

This test is not good because it avoids all mocks.

Mocks can be useful.

It is good because the test speaks in application language.

  • It calls PlaceOrderAsync.
  • It receives a PlaceOrderResult.
  • It asserts PaymentFailed.
  • The setup supports the behavior being tested.
  • It does not dominate the test.

By contrast, a test may become more fragile if it focuses mainly on interactions:

[Fact]
public async Task PlaceOrderAsync_CallsDependenciesInOrder()
{
    var repository = new MockOrderRepository();
    var paymentGateway = new MockPaymentGateway();
    var inventoryClient = new MockInventoryClient();
    var emailSender = new MockEmailSender();
    var service = new OrderService(
        repository,
        paymentGateway,
        inventoryClient,
        emailSender,
        new NullLogger<OrderService>());
        
    await service.PlaceOrderAsync(
        new PlaceOrderRequest("customer-1", "cart-1"),
        CancellationToken.None);
        
    Assert.True(repository.WasCalled);
    Assert.True(paymentGateway.WasCalled);
    Assert.True(inventoryClient.WasCalled);
    Assert.True(emailSender.WasCalled);
}

This test may still have value.

Sometimes order and collaboration matter.

But if most tests look like this, the test suite may be protecting implementation details rather than application behavior.

The test says that certain dependencies were called.

It does not say much about what the workflow means.

That can make the design harder to change.

If the workflow later publishes an event instead of sending an email directly, the behavior may still be correct. But the test may fail because the interaction changed.

If the payment step moves behind a more meaningful collaborator, the behavior may still be correct. But the test may fail because a different dependency was called.

If the service becomes clearer internally, the tests may still break because they were coupled to the previous procedure.

Being easy to mock helped create the test.

It did not guarantee that the test was testing the right thing.

This is why DI should not be treated as the whole testability story.

A testable design also needs clear boundaries, meaningful inputs, meaningful outputs, and behavior that can be observed without knowing too much about the internal wiring.

For example, a use case that returns an application result is often easier to test than a use case that only throws, logs, redirects, or calls other services.

public sealed record RestoreLicenseResult(
    RestoreLicenseStatus Status);

A test can assert the result directly:

Assert.Equal(
    RestoreLicenseStatus.NotFound,
    result.Status);

That is clearer than verifying that a repository returned null, a logger was called, an email was not sent, and a controller later returned a specific page.

Those details may matter in other tests.

But the application behavior should have a direct expression.

Good testability also depends on where framework details stop.

If an application service returns IActionResult, tests may need to inspect web framework results just to verify application behavior.

If an application service depends on HttpContext, tests may need to construct or fake HTTP state just to test a workflow rule.

If an application service depends on DbContext, tests may need database setup for behavior that is not really about persistence.

DI can inject all of those things.

But injecting them does not make them good application dependencies.

For example:

public sealed class FeedbackService
{
    private readonly IHttpContextAccessor _httpContextAccessor;
    
    public FeedbackService(IHttpContextAccessor httpContextAccessor)
    {
        _httpContextAccessor = httpContextAccessor;
    }
}

This service can be tested.

A test can fake IHttpContextAccessor.

But the test now has to understand HTTP context.

If the service only needs the current user’s email address, a better dependency might be:

public interface ICurrentUser
{
    string? EmailAddress { get; }
}

Now the test can provide the application concept directly.

It does not need to build framework state.

The improvement is not only that the dependency is easier to mock.

The improvement is that the dependency is closer to the responsibility being tested.

Testability improves when the design uses the right language.

The same applies to persistence.

A repository can be injected and mocked:

private readonly IArticleRepository _articleRepository;

But if the repository exposes storage-shaped operations, tests may still need to know too much about persistence details.

For example, if the application service asks for ArticleEntity, the test must create a persistence-shaped object.

If the service asks for IQueryable<ArticleEntity>, the test may need to simulate query behavior.

If the service catches database-specific exceptions, the test may need to construct technical failures.

A better boundary gives the test application-shaped concepts:

var article = Article.CreateDraft(
    "article-1",
    "Draft article");

or:

repository.AddEditableArticle(article);

or:

var result = await service.PublishAsync(
    new PublishArticleRequest("article-1", publishedAt),
    CancellationToken.None);

These tests are easier to read because the design is easier to reach.

Dependency Injection enables replacement.

Design determines what is being replaced.

That difference is important.

If the dependency is a technical mechanism, the test replaces a technical mechanism.

If the dependency is an application concept, the test replaces an application concept.

The second is usually easier to understand.

Another sign of poor testability is excessive setup.

A test may begin with many lines of mock configuration before the behavior is visible:

paymentGateway.WhenCaptureCalledReturn(PaymentResult.Succeeded());
inventoryClient.WhenReserveCalledReturn(InventoryResult.Available());
repository.WhenGetOrderCalledReturn(order);
emailSender.WhenSendCalledReturn(EmailSendResult.Succeeded());
clock.SetNow(now);

Some setup is normal.

But if every test requires a large amount of unrelated setup, the class may be doing too much or depending on collaborators at the wrong level.

A useful question is:

How much of this test setup is essential to the behavior being tested?

If a test about payment failure also needs to configure email templates, analytics tracking, inventory formatting, and logging behavior, the boundaries may not be focused enough.

Another useful question is:

Does the test assert an application outcome, or only a set of calls?

Both kinds of assertions can be valid.

But a test suite that mostly verifies calls between injected services may be too tightly coupled to the current implementation.

Application outcomes usually make tests more resilient.

They also make tests better documentation.

Dependency Injection can also make it easy to over-mock.

A developer may mock every interface because every interface is mockable.

But not every dependency needs to be mocked.

Small value objects can be created directly.

Domain objects can often be tested directly.

Simple policies can use real implementations.

In-memory fakes may be clearer than mocks for repositories or providers.

A real implementation may be preferable when it is deterministic, fast, and has no external side effects.

For example, a DiscountPolicy might not need to be mocked.

It may be better to use the real policy in the test, because the policy is part of the behavior being tested.

Mocking it may hide the actual decision.

The goal is not to mock as much as possible.

The goal is to isolate the right thing.

That requires design judgment.

A useful question is:

Am I replacing this dependency because it is external, slow, unpredictable, or irrelevant to this test — or only because DI makes it easy?

If a dependency is an external provider, database, clock, message sender, or current-user source, replacing it may make sense.

If a dependency is a small deterministic rule, replacing it may remove the behavior the test should protect.

Testability is strongest when the design gives tests clear entry points.

  • A use case method with a request and result.
  • A policy with explicit inputs and outputs.
  • A domain object with meaningful methods.
  • A repository boundary that can be faked in application language.
  • An adapter boundary that can be tested separately.

Those shapes make tests easier because the responsibilities are clear.

DI can help assemble those shapes.

It cannot create them by itself.

A mockable constructor is a useful feature.

But the real testability of a design comes from whether behavior is easy to reach, easy to observe, and easy to describe.

Dependency Injection can make objects easier to construct.

Good design makes behavior easier to test.4

9. Good Design Decides What Should Depend on What

Dependency Injection helps supply dependencies.

It does not decide which dependencies should exist.

That decision belongs to design.

A class may receive a dependency through its constructor. The dependency may be an interface. The implementation may be registered correctly in the container. The lifetime may be appropriate. The dependency may be easy to mock.

But the central design question still remains:

Should this class depend on that concept at all?

That question is often more important than how the dependency is injected.

For example:

public sealed class ArticlePublishingService
{
    private readonly IArticleRepository _articleRepository;
    private readonly IHttpContextAccessor _httpContextAccessor;
    
    public ArticlePublishingService(
        IArticleRepository articleRepository,
        IHttpContextAccessor httpContextAccessor)
    {
        _articleRepository = articleRepository;
        _httpContextAccessor = httpContextAccessor;
    }
}

This class uses DI.

The dependencies are explicit.

The service may be easy to construct in tests.

But the application service now depends on an HTTP mechanism.

That should raise a design question.

Does publishing an article need HTTP context?

Or does it need a user id, a permission, or an application-level actor?

A better design usually keeps the HTTP dependency near the web boundary:

var request = new PublishArticleRequest(
    ArticleId,
    CurrentUserId,
    PublishedAt);

The application service can then depend on the application request:

public async Task<PublishArticleResult> PublishAsync(
    PublishArticleRequest request,
    CancellationToken ct)
{
    // Publish article.
}

The dependency has not merely been moved.

It has been translated.

The web layer knows how to get the current user from HTTP context.

The application layer knows that publishing is performed by a user.

Those are different responsibilities.

Dependency Injection can provide IHttpContextAccessor.

Design decides whether the application service should know it exists.5

The same issue appears with persistence.

For example:

public sealed class ArticlePreviewService
{
    private readonly DbContext _dbContext;
    
    public ArticlePreviewService(
        DbContext dbContext)
    {
        _dbContext = dbContext;
    }
}

This may work.

The database context can be injected.

The lifetime can be scoped.

The service can query the database.

But the design question is whether an application service should depend directly on a persistence mechanism.

Sometimes that may be acceptable in a small application.

But if the application is trying to protect boundaries, a repository or query abstraction may be clearer:

public interface IArticlePreviewRepository
{
    Task<ArticlePreview?> GetPreviewAsync(
        string articleId,
        CancellationToken ct);
}

Now the application service asks for what it needs.

It does not know whether the preview comes from JSON, SQL Server, SQLite, a cache, or another source.

Again, DI did not create the design.

DI only wires the chosen dependency.

The design is in the dependency direction and the language of the abstraction.

Good design usually tries to keep dependencies pointing toward stable meaning, not toward convenient mechanisms.

  • An application service should depend on application concepts.
  • A domain rule should depend on values and policies, not on web or database frameworks.
  • Infrastructure adapters should depend on technical providers.
  • UI code should depend on presentation concepts and translate into application requests.
  • Composition code should know how to assemble everything.

Those are responsibility decisions.

DI can support them, but it cannot infer them.

For example, this dependency may look abstract:

private readonly IEmailSender _emailSender;

But whether it belongs depends on the class receiving it.

If the class is an infrastructure notification adapter, IEmailSender may be exactly right.

If the class is a registration workflow, perhaps the dependency should be more specific:

private readonly IWelcomeMessageSender _welcomeMessageSender;

If the class is a password reset workflow, perhaps it should depend on:

private readonly IPasswordResetMessageSender _passwordResetMessageSender;

These names are less generic.

But they express what the workflow needs.

The workflow does not need to know how to send arbitrary email. It needs a welcome message or a password reset message to be sent.

A more specific dependency can protect the application from low-level communication details.

It also makes tests clearer.

A test of registration can assert that a welcome message was requested. It does not need to build email subjects, templates, recipients, provider options, or SMTP messages unless those are the behavior being tested.

Good dependency decisions also affect what changes together.

If many unrelated classes depend directly on a low-level provider, a provider change may spread through the system.

If the provider sits behind an application-level adapter, the change can remain local.

For example:

public interface IPaymentGateway
{
    Task<PaymentResult> CaptureAsync(
        PaymentRequest request,
        CancellationToken ct);
}

This may be a useful infrastructure boundary.

But the application service should still not become provider-shaped.

If the provider’s result codes, exception types, retry rules, and terminology leak into the application, the interface has not protected enough.

A stronger application boundary may translate provider results into application outcomes:

public enum PlaceOrderStatus
{
    Succeeded,
    PaymentRejected,
    InventoryUnavailable,
    CustomerNotAllowed
}

The payment adapter may still know about provider-specific response codes.

The application service should usually know about application outcomes.

That is a design decision.

It decides which language travels inward and which language stays near the edge.

Dependency Injection cannot make that decision.

It can only supply the adapter once the boundary has been chosen.

A useful way to think about dependency direction is to ask what each layer should be allowed to know.

The web layer may know about HTTP, routes, model binding, cookies, claims, redirects, and status codes.

The application layer may know about use cases, requests, results, workflows, permissions, policies, and expected outcomes.

The domain layer may know about core rules, values, state transitions, and invariants.

The infrastructure layer may know about databases, files, providers, protocols, clients, messages, configuration, and technical errors.

The composition root may know about all of them because it assembles the system.

When a dependency crosses those lines, the question is not only whether it can be injected.

The question is whether it should be known there.

For example:

public sealed class LicenseValidationService
{
    private readonly IOptions<StripeOptions> _stripeOptions;
    public LicenseValidationService(
        IOptions<StripeOptions> stripeOptions)
    {
        _stripeOptions = stripeOptions;
    }
}

This may be technically easy.

But it is suspicious.

License validation should probably not depend on Stripe configuration. Stripe may be involved in purchase fulfillment, billing, or subscription status. But the validation use case should usually speak in terms of licenses, entitlements, devices, and validation outcomes.

A more suitable dependency might be:

private readonly ILicenseEntitlementStore _entitlementStore;

or:

private readonly ISubscriptionStatusProvider _subscriptionStatusProvider;

The exact design depends on the application.

The principle is that the dependency should match the responsibility.

A class should not depend on a technical provider simply because the provider is the current source of information.

It should depend on the concept it needs.

This also applies inside the application layer.

One application service can depend on another, but that dependency should be treated carefully.

For example:

public sealed class CheckoutService
{
    private readonly CustomerService _customerService;
    private readonly OrderService _orderService;
    private readonly PaymentService _paymentService;
}

This can become a chain of broad services that call each other because each one already has useful methods.

That may create hidden coupling between workflows.

A clearer design may depend on narrower collaborators:

private readonly ICustomerEligibilityPolicy _customerEligibilityPolicy;
private readonly IOrderFactory _orderFactory;
private readonly IPaymentCapturer _paymentCapturer;

These dependencies are shaped around the checkout workflow.

They are not just broad services reused for convenience.

Again, DI can wire either design.

Only design judgment decides which dependencies express the right responsibilities.

A useful question is:

Does this dependency point to a responsibility, or to a convenience?

A responsibility dependency helps the class express its purpose.

A convenience dependency gives the class access to something useful, but may pull in more knowledge than it should have.

Another useful question is:

If this dependency changed, would this class have a real reason to change?

If the answer is yes, the dependency may belong.

If the answer is no, the class may be coupled to a detail that should be hidden elsewhere.

For example, if a change in email template rendering forces a license activation service to change, the service may know too much about notification details.

If a change in web authentication forces a domain policy to change, the policy may depend on the wrong concept.

If a change in database indexing forces a page model to change, persistence details may have traveled too far.

Good design tries to make those changes local.

Dependency Injection can help by making dependencies explicit and replaceable.

But replaceable is not the same as appropriate.

  • A dependency can be replaceable and still wrong.
  • A dependency can be mockable and still too technical.
  • A dependency can be registered cleanly and still point in the wrong direction.
  • A dependency can be hidden behind an interface and still expose the wrong language.

That is why design must come first.

  • Design decides what each part is responsible for.
  • Design decides what each part is allowed to know.
  • Design decides which concepts should cross boundaries.
  • Design decides which details should stay near the edges.
  • Design decides whether a dependency represents meaning or mechanism.

Dependency Injection is useful after those decisions have been made.

It supplies the objects.

It does not choose the relationships.

Good design decides what should depend on what.

DI only helps make that decision executable.

10. Using DI as a Supporting Mechanism

Dependency Injection is most valuable when it supports a design that already has clear responsibilities.

  • It should help assemble the system.
  • It should make dependencies visible.
  • It should keep construction decisions out of application behavior.
  • It should allow infrastructure details to be supplied from the outside.
  • It should make tests easier to set up at the right boundaries.

But it should not be asked to do the design work.

A healthy use of DI usually starts with responsibility, not registration.

The first question is not:

What services should I register?

The first question is:

What responsibilities does this part of the application have?

After that, DI can help supply the collaborators that responsibility needs.

For example, a publishing workflow might be designed around a clear application operation:

public interface IArticlePublishingService
{
    Task<PublishArticleResult> PublishAsync(
        PublishArticleRequest request,
        CancellationToken ct);
}

That interface describes an application capability.

  • It does not describe the database.
  • It does not describe the web framework.
  • It does not describe how notifications are sent.
  • It does not describe how the object is constructed.

It describes what the application can do.

The implementation can then receive the dependencies needed to perform that responsibility:

public sealed class ArticlePublishingService : IArticlePublishingService
{
    private readonly IArticleRepository _articleRepository;
    private readonly IClock _clock;
    private readonly IArticlePublishedEvents _articlePublishedEvents;
    
    public ArticlePublishingService(
        IArticleRepository articleRepository,
        IClock clock,
        IArticlePublishedEvents articlePublishedEvents)
    {
        _articleRepository = articleRepository;
        _clock = clock;
        _articlePublishedEvents = articlePublishedEvents;
    }
    
    public async Task<PublishArticleResult> PublishAsync(
        PublishArticleRequest request,
        CancellationToken ct)
    {
        var article = await _articleRepository.GetEditableArticleAsync(
            request.ArticleId,
            ct);
            
        if (article is null)
        {
            return PublishArticleResult.NotFound();
        }
        
        var publishedAt = request.PublishedAt ?? _clock.Now;
        
        if (!article.CanBePublished(publishedAt))
        {
            return PublishArticleResult.NotReady();
        }
        
        article.Publish(publishedAt);
        
        await _articleRepository.SaveAsync(article, ct);
        
        await _articlePublishedEvents.PublishAsync(
            new ArticlePublished(article.Id, publishedAt),
            ct);
            
        return PublishArticleResult.Succeeded();
    }
}

This service still uses DI.

But the injected dependencies support the use case.

They do not define it.

The service asks a repository for an editable article. It uses a clock because the workflow needs time. It publishes an application event because other parts of the system may react to publishing.

Those dependencies make sense because the responsibility is clear.

The registration then becomes a technical assembly step:

services.AddScoped<IArticlePublishingService, ArticlePublishingService>();
services.AddScoped<IArticleRepository, ArticleRepository>();
services.AddSingleton<IClock, SystemClock>();
services.AddScoped<IArticlePublishedEvents, ArticlePublishedEvents>();

This code is important.

But it is no longer where the design is hidden.

A developer can understand the publishing workflow by reading the application service, request, result, and related abstractions. The DI registration only explains how the pieces are connected at runtime.

That is the right relationship.

Design first.

DI second.

This also means that dependencies should be chosen at the right level of abstraction.

For example, an application service should usually not depend on an SMTP client, HTTP context, database context, or provider-specific options unless its responsibility genuinely belongs near those mechanisms.

Instead, the application service should depend on concepts that fit the application language:

ICurrentUser
IClock
IArticleRepository
IPublishingPolicy
IArticlePublishedEvents

Infrastructure can still exist behind those abstractions.

ICurrentUser may be implemented using HTTP context.

IClock may be implemented using the system clock.

IArticleRepository may be implemented using SQL Server, SQLite, JSON files, or another store.

IArticlePublishedEvents may send messages to in-process handlers, a queue, or another integration point.

The application does not need to know those details.

DI supplies the implementations.

The boundary decides the language.

Using DI well also means keeping the composition root in its proper role.

The composition root should know how the application is assembled.

  • It may know which implementation satisfies each abstraction.
  • It may know which services are scoped, singleton, or transient.
  • It may know where configuration comes from.
  • It may know which provider is used in production and which substitute is used in tests.

But it should not be the only place where the application behavior is understandable.

For example:

services.AddScoped<IEmailSender, SmtpEmailSender>();
services.AddScoped<IWelcomeMessageSender, WelcomeMessageSender>();

This registration tells us how welcome messages are sent.

But the design should be clear from the application dependency:

private readonly IWelcomeMessageSender _welcomeMessageSender;

The registration can change from SMTP to another provider without changing the registration workflow’s language.

That is DI supporting design.

It also helps to keep technical dependencies near technical boundaries.

For example, SMTP-specific options should usually be used inside the SMTP implementation:

public sealed class SmtpEmailSender : IEmailSender
{
    private readonly SmtpOptions _options;
    public SmtpEmailSender(
        IOptions<SmtpOptions> options)
    {
        _options = options.Value;
    }
}

An application service should usually not need to know about SmtpOptions.

It should depend on the need to send a message, not on the configuration mechanism that makes sending possible.

That keeps provider changes local.

DI can also support testing when abstractions match responsibilities.

A test can replace a repository, clock, event publisher, or current user with a simple fake:

var service = new ArticlePublishingService(
    new FakeArticleRepository(),
    new FixedClock(publishedAt),
    new RecordingArticlePublishedEvents());

This is useful because the fake dependencies correspond to meaningful roles in the workflow.

The test does not need to fake HTTP context, SMTP settings, database tracking, route values, or container behavior.

It can focus on the application behavior.

That is the kind of testability DI should support.

The same principle applies when a dependency is introduced.

Before adding a dependency to a constructor, ask:

What responsibility does this dependency represent?

If the answer is technical, ask whether the current class is the right place for it.

If the answer is vague, ask whether the dependency should be more specific.

If the answer is “because this class needs to call that service”, ask what application concept that call represents.

For example, instead of this:

private readonly IEmailSender _emailSender;
private readonly ITemplateRenderer _templateRenderer;

a workflow might depend on this:

private readonly IPasswordResetMessageSender _passwordResetMessageSender;

That does not mean every email should have its own interface.

It means the dependency should match the responsibility at the receiving boundary.

Sometimes a generic sender is fine.

Sometimes a workflow-specific collaborator protects meaning better.

DI should make either choice easy.

Design decides which choice is right.

Another practical habit is to keep constructors honest.

A constructor should show what the class needs.

If the list grows, do not immediately hide it behind an options object, service locator, or dependency bundle.

  • Read it.
  • Group dependencies by method.
  • Look for dependencies from the wrong layer.
  • Look for dependencies that only support side effects.
  • Look for broad services used as convenience access points.
  • Look for technical mechanisms that could be translated into application concepts.

The constructor is often one of the clearest design review tools DI gives you.

Use that signal.

Do not hide it too quickly.

Using DI well also means avoiding unnecessary indirection.

Not every class needs an interface.

Not every helper needs to be registered.

Not every value object needs to be injected.

Not every deterministic policy needs to be mocked.

Not every private method needs to become a service.

If a dependency does not represent a boundary, variation point, external mechanism, or meaningful collaborator, direct construction may be simpler.

For example, a small immutable value object can usually be created directly:

var period = ReportingPeriod.ForMonth(year, month);

A deterministic domain rule may be called directly:

if (!article.CanBePublished(publishedAt))
{
    return PublishArticleResult.NotReady();
}

A simple private formatting helper may not need to become an injected service unless it has a reason to vary or be reused across boundaries.

DI is not a goal by itself.

It is a tool for assembling dependencies that should already exist for design reasons.

A useful rule of thumb is:

Inject collaborators, not every object.

A collaborator helps the class fulfill its responsibility.

A value object represents data or meaning.

A domain object owns state or behavior.

An infrastructure adapter connects to the outside world.

A composition component wires things together.

Those roles should not all be treated the same just because the container can create them.

The container should not become the default answer to every construction question.

Manual construction is sometimes clearer.

Factory methods are sometimes clearer.

Static pure functions are sometimes fine.

Value objects are often created directly.

Domain objects may be loaded from repositories or created through factories.

Infrastructure clients may be registered centrally.

Application services may be injected.

The important part is that the construction mechanism follows the design, not the other way around.

DI is at its best when it fades into the background.

The reader sees application requests, results, policies, workflows, repositories, adapters, and events.

The container is there, but it is not the main story.

When the design is clear, DI becomes boring.

That is a good sign.

It means the container is doing what it should do: assembling a system whose responsibilities already make sense.

11. Conclusion

Dependency Injection is a valuable technique.

It helps make dependencies visible. It moves construction decisions out of the classes that use those dependencies. It supports testing, configuration, lifetime management, infrastructure replacement, and application composition. It can reduce hard-coded coupling and make systems easier to assemble.

Those benefits matter.

But Dependency Injection is not design.

  • It does not decide whether a class has the right responsibility.
  • It does not decide whether an interface represents a meaningful boundary.
  • It does not decide whether a service is too broad.
  • It does not decide whether a dependency belongs in the layer that receives it.
  • It does not decide whether a workflow is expressed in application language or only distributed across injected services.

DI can make dependencies explicit.

It cannot make them appropriate.

That distinction is important because DI can make a design look cleaner than it really is.

A class with constructor injection may still depend on the wrong concepts.

An interface may still expose persistence or framework details.

A service registration file may still assemble unclear responsibilities.

A correct lifetime may still manage a poorly designed component.

A mockable class may still be difficult to test meaningfully.

A chain of injected services may still be a procedural script split across many objects.

In all of these cases, DI solves a construction problem.

The design problem remains.

Good design begins with responsibility.

  • What is this class responsible for?
  • What should this use case own?
  • What should this layer be allowed to know?
  • Which concepts should cross this boundary?
  • Which details should stay near the edge?
  • Which dependencies represent application meaning, and which only represent technical mechanisms?

Those questions cannot be answered by the container.

They must be answered before the container is asked to assemble the result.

A useful way to think about DI is this:

Dependency Injection should reveal design decisions, not replace them.

A constructor should show what a class needs.

An interface should show what boundary or concept it protects.

A registration should show how already meaningful parts are connected.

A lifetime should support the role of the object.

A test double should replace a dependency at the right boundary.

When DI is used this way, it becomes a useful design aid.

  • It makes questionable dependencies visible.
  • It makes long constructors harder to ignore.
  • It makes technical mechanisms easier to move toward the edges.
  • It makes application services easier to test through requests and results.
  • It makes infrastructure adapters easier to replace.
  • It makes the composition root a clear assembly point rather than a hidden design model.

But that only happens when the design is already being considered.

Without that design attention, DI can also hide problems.

  • A broad service can keep growing because adding one more injected dependency is easy.
  • A weak abstraction can look better because it has an interface.
  • A framework concern can enter the application layer behind an injected wrapper.
  • A workflow can become a chain of small services with no clear owner.
  • A service locator can hide what a class really depends on.
  • A dependency bundle can make a constructor shorter while keeping the same unclear responsibility.

These are not failures of DI itself.

They are signs that the tool is being asked to do more than it can do.

DI should support boundaries.

It should not be mistaken for them.

It should support testability.

It should not reduce testing to mock setup.

It should support composition.

It should not make the container the only place where the application can be understood.

It should support flexibility.

It should not introduce abstraction without meaning.

The best use of DI is often quiet.

The application code speaks in terms of use cases, policies, results, repositories, adapters, events, and domain concepts. The constructor dependencies are understandable. The interfaces protect real boundaries. The registration code is boring. The lifetimes are technically correct but not conceptually dominant. The tests can reach behavior without recreating the whole runtime environment.

In that kind of system, DI is still important.

But it is not the main story.

The main story is that responsibilities are clear.

That is the point worth keeping.

Injecting a dependency can make code easier to assemble.

Choosing the right dependency makes code easier to understand.

Dependency Injection helps with the first.

Design must still do the second.