ぼやっとは理解してたけど、この記事を見て知識が定着した気がする。 DI・DIコンテナ、ちゃんと理解出来てる・・? - Qiita この記事ではDIとDIコンテナとサービスロケータについて触れてたけど、 ここではDIについてだけ改めて自分でまとめてみる。 サンプルケース 例えばこんなコードがある。 ※phpぽいけど疑似コードです。 class Human { public void function __construct(string name) { this->brain = new Database() # DBアクセスライブラリ this->name = name } # 覚える public void function memolize(string keyword, string some_string){ this->brain.save(keyword, some_strin