<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/ZvxhM4Soh" -->

---
title: Day 6/30 — Dependency Injection Is Your Superpower
description: Dependency injection is a way for a class to explicitly declare its dependencies, making the constructor serve as documentation, architecture, and a testing...
canonical: https://daily.dev/posts/day-6-30-dependency-injection-is-your-superpower-zvxhm4soh
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Day 6/30 — Dependency Injection Is Your Superpower | daily.dev
og:description: Dependency injection is a way for a class to explicitly declare its dependencies, making the constructor serve as documentation, architecture, and a testing...
og:url: https://daily.dev/posts/day-6-30-dependency-injection-is-your-superpower-zvxhm4soh
og:image: https://api.daily.dev/og/posts/ZvxhM4Soh.png
og:image:alt: Day 6/30 — Dependency Injection Is Your Superpower
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Day 6/30 — Dependency Injection Is Your Superpower

**[Nestjs Developers](https://daily.dev/sources/nestjsdevs)** · [@ezilemdodana](https://daily.dev/ezilemdodana) · 1 min read · 125 upvotes · 11 comments

## Summary

Dependency injection is a way for a class to explicitly declare its dependencies, making the constructor serve as documentation, architecture, and a testing seam. Abusing DI by using service locators or accessing global state defeats its purpose and hides true dependencies.

## Content

Dependency injection is not unnecessary ceremony.

It is how a class tells the truth about what it needs.

```
constructor(
  private readonly orders: OrdersRepository,
  private readonly payments: PaymentsGateway,
) {}
```

That constructor is documentation, architecture and a testing seam.

The warning sign is a class that accesses global state or uses `ModuleRef` to locate dependencies everywhere.

That turns dependency injection back into a service locator.

Where have you seen dependency injection abused?

#NestJS #DependencyInjection #Testing

## Community discussion

Top comments from developers on daily.dev.

**@adarshks** · 6 upvotes

> Dependency Injection is a design pattern where a class receives its dependencies from the **IoC **container instead of creating them itself.

**@h3l0st3k** · 2 upvotes

> One challenge I've noticed is that teams often use Dependency Injection correctly, but every project organizes modules, folders, and documentation differently.The result is that good architectural practices become harder to understand when moving between projects. I'm curious whether software standards could help reduce that friction.

**@shaikhnaasir** · 2 upvotes

> Awesome

**@rujorgensen** · 1 upvotes

> Don't even get me started on the chilling, and now, sadly, widely adopted, anti-pattern horror of Angular's `inject` function 😱😱😱!

**@ahmetozel** · 1 upvotes

> The abuse I see most is injecting a large service that exposes twenty unrelated methods, which hides the real dependency almost as effectively as a service locator. Narrow ports such as OrdersReader or PaymentAuthorizer make the constructor describe capability, not just object ownership. I would also treat request-scoped providers carefully in NestJS because one scoped dependency can pull an entire graph into per-request instantiation. DI helps when the lifetime and boundary are explicit, not merely because a container created the object.

---

Tags: [#testing](https://daily.dev/tags/testing), [#architecture](https://daily.dev/tags/architecture), [#dependency-injection](https://daily.dev/tags/dependency-injection), [#nestjs](https://daily.dev/tags/nestjs)

[View this post on daily.dev](https://daily.dev/posts/day-6-30-dependency-injection-is-your-superpower-zvxhm4soh)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"DiscussionForumPosting","mainEntityOfPage":"https://daily.dev/posts/day-6-30-dependency-injection-is-your-superpower-zvxhm4soh","headline":"Day 6/30 — Dependency Injection Is Your Superpower","text":"Dependency injection is a way for a class to explicitly declare its dependencies, making the constructor serve as documentation, architecture, and a testing seam. Abusing DI by using service locators or accessing global state defeats its purpose and hides true dependencies.","url":"https://daily.dev/posts/day-6-30-dependency-injection-is-your-superpower-zvxhm4soh","datePublished":"2026-08-02T07:35:02.069Z","dateModified":"2026-08-02T20:17:32.245Z","author":{"@type":"Person","name":"Ezile Mdodana","url":"https://daily.dev/ezilemdodana","image":"https://media.daily.dev/image/upload/s--1OI8gwnO--/f_auto/v1771923757/avatars/avatar_7vB9SeLRKhOHGnzEpmFvQ?_a=BAMAMiiu0","description":"Software Project Lead sharing practical insights on NestJS, Angular, AWS and scalable systems.","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":8430}},"image":"https://media.daily.dev/image/upload/s--68lNWF8W--/f_auto/v1785656103/posts/ZvxhM4Soh?_a=BAMAMicg0","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":125},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":11}],"comment":[{"@type":"Comment","text":"Dependency Injection is a design pattern where a class receives its dependencies from the **IoC **container instead of creating them itself.","datePublished":"2026-08-03T05:02:58.143Z","url":"https://daily.dev/posts/ZvxhM4Soh#c-gI7X4Ntjq","author":{"@type":"Person","name":"Adarsh KS","url":"https://daily.dev/adarshks","image":"https://media.daily.dev/image/upload/s--AOhSU9kx--/f_auto/v1785742065/avatars/avatar_gdco5dGLTOCNm55DPuark?_a=BAMAMicg0"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":6}},{"@type":"Comment","text":"One challenge I’ve noticed is that teams often use Dependency Injection correctly, but every project organizes modules, folders, and documentation differently.The result is that good architectural practices become harder to understand when moving between projects. I’m curious whether software standards could help reduce that friction.","datePublished":"2026-08-03T11:58:51.422Z","url":"https://daily.dev/posts/ZvxhM4Soh#c-ZSnj90DD3","author":{"@type":"Person","name":"H3l!0s_T3k","url":"https://daily.dev/h3l0st3k","image":"https://avatars.githubusercontent.com/u/90980178?v=4"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2}},{"@type":"Comment","text":"Awesome","datePublished":"2026-08-04T06:20:39.897Z","url":"https://daily.dev/posts/ZvxhM4Soh#c-pUhBVmlCr","author":{"@type":"Person","name":"Shaikh Naasir","url":"https://daily.dev/shaikhnaasir","image":"https://avatars.githubusercontent.com/u/166585409?v=4"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2}},{"@type":"Comment","text":"Don’t even get me started on the chilling, and now, sadly, widely adopted, anti-pattern horror of Angular’s inject function 😱😱😱!","datePublished":"2026-08-03T20:54:45.445Z","url":"https://daily.dev/posts/ZvxhM4Soh#c-xDXhCmisY","author":{"@type":"Person","name":"RJ","url":"https://daily.dev/rujorgensen","image":"https://lh3.googleusercontent.com/a/ACg8ocIX0FMQ5dZ_ie8ljouGWJQvP3wbIrYt5XnsaQf0l2ttkPDsSXLt=s96-c"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1}},{"@type":"Comment","text":"The abuse I see most is injecting a large service that exposes twenty unrelated methods, which hides the real dependency almost as effectively as a service locator. Narrow ports such as OrdersReader or PaymentAuthorizer make the constructor describe capability, not just object ownership. I would also treat request-scoped providers carefully in NestJS because one scoped dependency can pull an entire graph into per-request instantiation. DI helps when the lifetime and boundary are explicit, not merely because a container created the object.","datePublished":"2026-08-05T17:33:10.061Z","url":"https://daily.dev/posts/ZvxhM4Soh#c-HQbcsvbPN","author":{"@type":"Person","name":"Ahmet Özel","url":"https://daily.dev/ahmetozel","image":"https://avatars.githubusercontent.com/u/70992231?v=4"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1}}],"isPartOf":{"@type":"WebPage","url":"https://daily.dev/squads/nestjsdevs","name":"Nestjs Developers"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Nestjs Developers","item":"https://daily.dev/squads/nestjsdevs"},{"@type":"ListItem","position":3,"name":"Day 6/30 — Dependency Injection Is Your Superpower"}]}
```

