Active Record の哲学

rails で使われている ORM である Active Record。当たり前のように広く使われているが、Active Record は何を解決するのか?

Active Record の哲学

README に書いてある。

Philosophy - rails/activerecord

Active Record attempts to provide a coherent wrapper as a solution for the inconvenience that is object-relational mapping. The prime directive for this mapping has been to minimize the amount of code needed to build a real-world domain model. This is made possible by relying on a number of conventions that make it easy for Active Record to infer complex relations and structures from a minimal amount of explicit direction.

「実世界のドメインモデルを構築するために必要なコードの量を最小限に抑える」(Google翻訳)とのこと。

たったこれだけなので、単純だなと思いそうになるが、「実世界のドメインモデルを構築するために」 というところでん?ってなった。

実世界のドメインモデルを構築?

Active Record の仕様をどれだけ分かっていても、実世界のドメインモデルを構築するだけの知識がないと Active Record は使えないということか。

結局、Active Record はただの道具にすぎなくて、先に 実世界のドメインモデルを構築する知識が必要 ということだろう、きっと。