勉強日記

チラ裏

DDD Part1 Ch.2 Communication and the Use of Language

www.informit.com

Ubiquitous Language

  • ドメイン専門家/開発者ともに、自分たちにしかわからない言葉を使いがち
  • 開発者とドメイン専門家との間で言葉の壁ができてしまう
    • バイリンガル」になろうとする者も現れるが...
      • その人律速になってしまうので良くない
      • 翻訳自体も不正確
  • 言葉の違いは混乱を生む
    • チームの面子の中で溝を生む
      • 気づかない
    • 言葉の翻訳に気を散らされ、モデルを深く理解することに集中できない
  • モデルをもとに共通言語をつくろう
    • 仕事の中のいたるところで現れる(ubiquitous)
  • ユビキタス言語は
    • モデルを構成するクラス名や操作からなる
    • モデル中で定義されている、ビジネスドメインのルールが含まれる
    • 設計パターンにより強化される
  • ユビキタス言語の単語や句として、モデルのセマンティクスが現れる
  • ユビキタス言語を徹底的に使うことで、モデルの弱点が浮き彫りになる
    • 足りない語句は補われる
    • 不適切なクラス名は改められる
      • 振る舞いを名前に合ったものに直すことも
    • 矛盾が正される
  • ドメイン専門家・開発者双方からユビキタス言語を正していく
    • ドメインの専門家からの指摘
      • ぎこちない
      • 意味が正しくない
    • 開発者からの指摘
      • あいまい
      • 矛盾
  • ユビキタス言語の修正、これすなわちモデルの修正、これすなわち実装の修正
    • リファクタ
    • リネーム

Working Out a Cargo Rounter

  • モデルベースのユビキタス言語で会話すると、単純かつわかりやすいよね、という例

Modeling Out Loud

  • 人間の語学能力はすごいよ、という話
  • 図面やドキュメントでコミュニケーションするよりも円滑で、細かなニュアンスも伝わる
  • 補遺 モデルの言葉で話す
    • どうすればシナリオを話しやすいかを考える
    • そこで生まれたアイデアをモデルに還元する

One Team, One Language

  • 開発とドメイン専門家とで違う言葉を使うのはよくないよ、という話
  • 開発は、ドメイン専門家を「保護」しがち
    • ドメイン専門家にとって抽象的すぎる」
      • 逆に開発はドメインをどれほど深く知っているのか(いや、知るまい)
    • ドメイン専門家は『オブジェクト』なんか知らない」
      • なんとなくはわかるはず
      • ドメイン専門家にとってわかり辛ければ、それはモデルが悪い
    • ドメイン専門家の言葉で要求を吸い上げなければ」
  • 開発者・ドメイン専門家一方にしかわからない言葉も確かに存在する
    • 開発者にしかわからない言葉
      • 実装にかかわるが、ドメイン専門家の関心事でないこと
    • ドメイン専門家にしかわからない言葉
    • いずれも、ユビキタス言語の補集合。言い換えであってはならない

Documents and Diagrams

  • UMLのクラス図やオブジェクト図は、関連や相互作用を表現するのに適している
    • が、長方形はオブジェクトの概念を伝えてくれない
    • ので、口頭で補ったり、他の参加要素として追加したりする
  • シンプルでカジュアルな図で、会話を補助する
    • オブジェクトの名前と関連を共有できるのが重要
    • あれこれ思考実験しながら書き直す
    • UMLはLanguageなのである
  • 「すべて」をUMLで表現しようとすると問題が生じる
    • 詳細をすべて詰め込んだところで、個々の部分は結局見えない(膨大すぎて読めない)
      • can't see the forest for thre trees.
  • オブジェクトの属性と関係だけではモデルのストーリーの半分しか表現できない
    • UMLで表現できず、自然言語の文章に頼るもの
      • ふるまい
      • 制約
    • シーケンス図等で暗示できるが、「記述」はできない
  • UMLはプログラム言語としても不十分
    • UMLからコード生成するのは生産性悪い
      • 箱と線で表現できないことをコード化できない
        • UML仕様外の文章とか
    • UMLでコード生成するようになると、それは「実装」であり、「モデル」としての意味が失われる
  • 図の利用は最小限に
    • イデアの骨組み・重要な部分の理解の助けに過ぎない
    • テキスト付の図よりは、図付きのドキュメント
      • 自然言語は微妙なニュアンスを伝えられるから

Written Design Documents

  • 口頭でのコミュニケーションだけでなく、文書も必要
    • 安定性
    • 共有容易性

Documents Should Complement Code And Speech

  • どれくらいドキュメンテーションするかは、開発プロセスによりけり
    • 例: XP
      • コード以外のドキュメントなし
        • 動いているコードとテスト自身に語らせる
          • 嘘をつかない
          • 曖昧さがない
      • 口頭でのコミュニケーションや、ホワイトボード上に書いた(すぐ消す)図面はこの限りではない
        • ずっと残って混乱を生じるおそれがないから
  • コード自体をドキュメントとする方法の限界
    • 詳細を追うのが大変
      • 曖昧さはないが、明快とも限らない
      • 結局、「図ですべてを表現する」のと同種の問題を抱えている
    • コードはプログラマにしか読めない
  • ドキュメントは、コードを補うものであるべき
    • (追うのが大変な)巨大な構造の理解を助ける
    • 言語仕様上、概念を素直に実装に落とし込めていない部分の補足

Documents Should Work For a Living And Stay Current

  • 筆者はドキュメントを書くとき、モデルの一部を切り出して図面化し、文章の中に埋め込む
    • カジュアルでいい。手書きだってかまわない
  • ドキュメントの価値
    • モデルの概念の説明
    • コードの詳細を追うのを助ける
    • モデルの想定する使われ方の理解
  • ドキュメントはプロジェクト活動に関わっていなければならない
    • ドキュメントの中の単語が、会話やコードの中に現れない
      • 誰も読まない・読みたいと思っていないということ
        • 巨大すぎ
        • 複雑すぎ
        • 大事なことに触れていない
    • ユビキタス言語の変化にドキュメントが追従しない
      • ドキュメントが必要とされていない
        • 更新するだけ労力の無駄
      • 古い情報は混乱のもと
  • ユビキタス言語で要求仕様書を書く
    • ユビキタス言語の定義自体にビジネス領域の知識が盛り込まれるため...
      • シンプルでわかりやすい
      • 曖昧さが少ない
        • 【補】曖昧な部分があったら、それは要求仕様書ではなく、
          ユビキタス言語の言葉の定義自体が曖昧
  • ドキュメントは、プロジェクトに追従できるよう、最小に
    • コードや会話を補う程度

Excutable Bedrock

  • よく書かれたコードはそれ自体コミュニケーションツールになる
    • 正しいことを「する」だけでなく、「自ら語る」コードに保つ必要あり
    • 「する」ことと「語る」ことに齟齬があると誤解を生む
      • メソッド名が、中身に反して嘘をついている
      • テストの変数名がストーリーを適切に表現していない
    • 宣言的デザインで、こういった齟齬を排除できる
    • 誤解を生むことはあれど、他のドキュメントよりは真実に近い
      • 効率のよいコミュニケーションのためには、ユビキタス言語で記述すること

Explanetory Models

  • 単一のモデルで実装・設計・チームのコミュニケーションを行うのがあくまで基本
  • 説明用のモデルを別途作ることは有用
    • 知らない人への説明用
      • 特定のトピックにスコープを絞っている
      • コミュニケーションしやすいよう仕立て直されている
    • UML等で表現しないほうがよい
      • 設計で使用するモデルと混同しないよう

英語

  • insight
    • an accurate and deep understanding.
    • 「洞察」って何だよとずっと思っていた
  • crucial
    • decisive or critical, especially in the success or failure of something.
  • pervade
    • (especially of a smell) spread through and be perceived in every part of.
  • ubiquitous
    • Present, appearing, or found everywhere.
  • supple
    • Bending and moving easily and gracefully; flexible.
  • call for
    • Make necessary.
      • "desperate times call for desperate measures"
      • 非常時には非常手段が求められる
  • devoid of
    • Entirely lacking or free from.
  • muddle
    • Bring into a disordered or confusing state.
  • conceal
    • Not allow to be seen; hide.
  • schism
    • A split or division between strongly opposed sections or parties, caused by differences in opinion or belief.
  • interplay
    • The way in which two or more things have an effect on each other.
  • blunt
    • Make or become less sharp.
  • anemic
    • having too few red blood cells, causing a lack of energy.
  • lowest common denominator
    • 最小共通項
  • pervasive
    • (especially of an unwelcome influence or physical effect) spreading widely throughout an area or a group of people.
    • 本文では、welcomeなことに使っている
  • unadulterated
    • (especially of food or drink) having no inferior added substances; pure.
    • Not mixed or diluted with any different or extra elements; complete and absolute.
      • 本文ではこっち
      • 単体の、くらいの意味
  • relentlessly
    • In an unceasingly intense or harsh way.
  • harsh
    • Having an undesirably strong effect
  • splinter
    • Break or cause to break into small sharp fragments.
  • populate
    • [Computing] Fill in (data).
  • customs clearance
    • 通関
  • concise
    • Giving a lot of information clearly and in a few words; brief but comprehensive.
  • layman
    • person without professional or specialized knowledge in a particular subject.
  • pidgin
    • often as modifier A grammatically simplified form of a language, typically English, Dutch, or Portuguese, some elements of which are taken from local languages, used for communication between people not sharing a common language.
    • 要するに混成語
  • hash something out
    • Come to agreement on something after lengthy and vigorous discussion.
  • exploit
    • Make full use of and derive benefit from (a resource)
  • addendum
    • An item of additional material added at the end of a book or other publication.
    • 補遺のこと
  • retrofit
    • Add (a component or accessory) to something that did not have it when manufactured.
  • fair
    • Just or appropriate in the circumstances.
  • anchor
    • Provide with a firm basis or foundation.
  • compel
    • [with object and infinitive] Force or oblige (someone) to do something.
  • clutter
    • Cover or fill (something) with an untidy collection of things.
  • tidy
    • Arranged neatly and in order.
  • uncluttered
    • 整理された
  • facilitate
    • Make (an action or process) easy or easier.
  • encompass
    • with object Surround and have or hold within.
  • all-encompassing
    • Including or covering everything or everyone; comprehensive.
  • obscure (verb)
    • Keep from being seen; conceal.
  • compulsion
    • (mass noun) The action or state of forcing or being forced to do something; constraint.
  • rigor, rigour
    • The quality of being extremely thorough and careful.
  • thorough
    • Complete with regard to every detail; not superficial or partial.
  • linger
    • Stay in a place longer than necessary because of a reluctance to leave.
  • reluctance
    • Unwillingness or disinclination to do something.
  • pare down
    • Reduce (something) in size, extent, or quantity in a number of small successive stages
  • compelling
    • Evoking interest, attention, or admiration in a powerfully irresistible way
  • evoke
    • Bring or recall (a feeling, memory, or image) to the conscious mind.
  • fastidious
    • (someone is) Very attentive to and concerned about accuracy and detail.
  • discrepancy
    • An illogical or surprising lack of compatibility or similarity between two or more facts
  • thrust
    • (mass noun) The propulsive force of a jet or rocket engine.