PoEAA Part 1 Chapter 1 Layering
- まえがき
- The Evolution of Layers in Enterprise Applications
- The Three Principal Layers
- Choosing Where To Run Your Layers
- 英語
まえがき
- レイヤ分けは普遍的
- レイヤ分けの性質
- 上のレイヤは下のレイヤのサービスを利用する
- 下のレイヤは、上のレイヤのことを知らない
- 上のレイヤは、直下のレイヤのことは知っているが、その下のレイヤのことは知らない(不透過性)
- 必ずしもそうとは限らない
- 完全にそうとは限らない
- レイヤ分けの利点
- レイヤ分けの欠点
- 何の層を作り、何の責務を負わせるか決めるのが一番難しい
The Evolution of Layers in Enterprise Applications
- 昔はレイヤ分けの概念がなかった
- 90年代、クライアント-サーバーに端を発する
- RDBのデータの表示・簡単な更新だけなら、この2層構造でよかった
- 複雑なビジネスロジックが絡むとそうはいかなくなる
- クライアント-サーバー構成と同時期に、OOが台頭
- 3層にしよう
- Presentation
- UI
- Domain
- ドメインロジック
- オブジェクトで構造化できる
- Data Source
- Presentation
- 3層にしよう
- 3層構造はなかなか流行らなかった
- 多くのシステムは(少なくとも最初は)シンプル
- シンプルならC-S2層構造用のツールやフレームワークが魅力的
- 3層構造に適用するのが困難であったり、不可能であったりした
- Webの台頭による激震
- layer / tier
- tier: 物理的に分かれていることを強調
- Client-Server は 2-tier system
- layer: 必ずしも物理的に分かれていないことを強調
- Presentation-Domain-DataSource は 3-layer system
- domainはデスクトップPCかDBサーバーかどちらかにある
- 2ノード3層
- DBがローカルで動いていれば1ノード3層
- tier: 物理的に分かれていることを強調
The Three Principal Layers
- Presentation Logic
- 結果の表示
- 入力の解釈・domain/data sourceのアクションへの変換
- Domain Logic (Business Logic)
- 入力値や保持している値の計算
- 入力のバリデーション
- どのData Source Logicを実行するかの決定
- Data Source Logic
- アプリケーションの動作上必要な他システムとの連携
- DB
- データ永続化
- トランザクションモニタ
- 他アプリケーション
- メッセージングシステム
- DB
- アプリケーションの動作上必要な他システムとの連携
- Domain LogicでData Sourceを完全に隠蔽することもある
- 実用上、完全には隠蔽しないこともよくある
- presentation層がdata sourceから直接データを取得し、domain logicに処理させて表示する
- 各層の中で複数のパッケージを作ることがある
- rich-client用/command line用のpresentationパッケージ
- domainを細分
- あるdomainパッケージからしか使わないdata sourceパッケージ
- エンドユーザーが動かさないプログラム
- presentation と data source とは、「アプリケーション外部と結合」という点で似ている
- Hexagonal Architectureの背景にある考え方
- 対称的
- Hexagonal Architectureの背景にある考え方
- 非対称も便利
- presentation
- 外部にサービスを提供するインタフェース
- data source
- サービスを提供されるインタフェース
- presentation
- 単純なスクリプトレベルでも、最低限3つのサブルーチンに分けなさい
- 複雑になっていったらクラスを分ける
- さらに複雑になったら、各層の中でパッケージングする
- domain/data source層がpresentation層に依存するのはNG
- domain層とdata source層の依存関係は複雑で、適用パターンにより違ってくる
- 何がドメインロジックで何がそうでないかの判定方法
Choosing Where To Run Your Layers
- システムが物理的な構造を有している場合、何をどこに置くか
- サーバーに配置
- 保守が容易
- 各クライアントを修正し、サーバーと同期する必要がない
- クライアント上の他ソフトウェアとの互換性の心配もない
- 保守が容易
- クライアントに配置
- 応答性がよい
- サーバーとの接続が切れても動作できる
- コードを配置したら、極力単一のプロセスで動かすように
- 本当に必要な場合を除き、プロセスを分けない
- プロセスを分けると、
Remote Facades
やData Transfer Objects
といったものの追加が必要になる
- 複雑性を加速させるものを極力避ける
- 分散システム
- 明示的なマルチスレッディング
- パラダイムの溝(オブジェクト/関連)
- マルチプラットフォーム
- 極端な性能要件
英語
- whole
- [noun] A thing that is complete in itself.
- hunt (somebody) down
- to search for someone until you catch or find them, especially in order to punish or harm them
- bandwagon
- Used in reference to an activity, cause, etc. that is currently fashionable or popular and attracting increasing support.
- make headway
- Make Forward movement or progress, especially when this is slow or difficult.
- headwayは [mass noun]
- compelling
- Evoking interest, attention, or admiration in a powerfully irresistible way.
- seismic
- Relating to earthquakes or other vibrations of the earth and its crust.
- crust
- The outermost layer of rock of which a planet consists, especially the part of the earth above the mantle.
- tier
- Each in a series of rows or levels of a structure placed one above the other.
- behalf
- In the interests of a person, group, or principle.
- mundane
- Lacking interest or excitement; dull.
- ありふれた
- dogmatic
- Inclined to lay down principles as undeniably true.
- jiggery-pokery
- Deceitful or dishonest behaviour.