nakaoka3の技術ブログ

2023年中に52本なにか書きます

オブジェクト指向プログラミングでなくてもドメイン駆動設計できるらしい

ドメイン駆動設計(DDD)というと、オブジェクト指向プログラミング言語というイメージが強かった。 Javaのようなクラスベースのオブジェクト指向プログラミング言語で、業務をモデリングするときの設計手法という印象だった。

Scott Wlaschin は 『Domain Modeling Made Functional 』で、関数型プログラミング言語のF# で ドメイン駆動設計をする手法を提案している。

pragprog.com

『Domain Modeling Made Functional』は3つのパートから成り立っていて、Part I. Understanding the Domain でしっかりとDDDの基本について丁寧に説明している。

関数型プログラミング言語について関心があって読んだが、予想よりも DDD のアプローチを丁寧に取り入れていて、DDDについての理解が深まった。

実はこの書籍よりも先に、Scott Wlaschin の動画を見た。動画もオススメだ。

www.youtube.com

また、DDDが向いているソフトウェアとそうでないものがあるということも 『Domain Modeling Made Functional 』 の最初で言及されている。

“Domain-driven design is not appropriate for all software development, of course. There are many types of software (systems software, games, and so on) that can be built using other approaches. However, it is particularly useful for business and enterprise software, where developers have to collaborate with other nontechnical teams, and that kind of software will be the focus of this book.” - Chapter 1, Domain Modeling Made Functional

いま仕事で小説投稿サイト1の開発をしている。小説家や出版社の編集者のような、DDDの用語でいうドメインエキスパートにあたる専門家が登場する。

ドメインエキスパートと開発者と知識の差の存在する分野なのでDDDは効果を発揮するのだろう。『Domain Modeling Made Functional 』で学んだ関数型プログラミングとDDDの組み合わせの知見を活かせる機会があるかも知れない。