---
title: "DI"
date: "2026-03"
category: "Design Patterns & Architecture"
tags: ["Design Patterns & Architecture"]
description: "The core of DI is defining structure, and there are generally two ways to do that, interface and abstract class. The key thing is that the DI container has to know the structure of the object it handles before it can do anything further with it..."
source: "https://enriquemark.com/en/posts/DI"
---

The core of DI is defining structure, and there are generally two ways to do that
	interface
	abstract class

The key thing is that the DI container has to know the structure of the object it handles before it can do anything further with it, and these two are both normally used to define structure. Or rather, more than structure, it's the operational type that matters. A type is a declaration about structure. The core of it is that I need to know what you look like before I can operate on you, and what you look like is what the type is there to tell apart.

More detail in [Dependency injection](/en/posts/依赖注入)

---

**Translation note.** I wrote this in Chinese. This English version is an LLM translation, so the wording is not mine even though the thinking is. Original: [DI](</zh-hant/posts/DI>).
