はじめに
「ドメイン駆動設計入門」を読んだ
プロジェクトの構成(どこに何を置くべきか)について少しわかった気になっている
WPFのフレームワークであるPrismが提供しているフルテンプレートに
ドメイン駆動の部品たちを追加し、軽量DDDをしてみようとして
"モジュール"の存在の前に挫折した記録
プロジェクト作成
Visual Studioを立ち上げて、Prsim Full App(.NET Core) を選択する
- 初期のモジュールが
ModuleName
という名前なので、ModuleA
に変更しておく -
RegionViewModelBase
は、それ単体で使うことがないので、抽象クラスに変更する
テンプレートに追加する項目
FullApp.Core
追加項目 | 内容 |
---|---|
DialogViewModelBase | ダイアログはこのクラスを継承する |
DialogNames | ハードコーディングを避けるために、自作したダイアログの名前を |
FullApp.Services.Interfaces
追加項目 | 内容 |
---|---|
IFullAppRepository | データを再構築・永続化するリポジトリのインターフェイス |
FullApp.Repositories
追加項目 | 内容 |
---|---|
EFInfrastructure | Entity FrameworkをつかってDBにアクセスする場合の実装 |
InMemoryInfrastructure | テスト時に疑似DBとしてつかう |
SnsApplication
解決したい課題に対するユースケースを実現する
モジュールにロジックは書く?
結論
モジュールにロジックを書いてもいい
Prism公式サイトのモジュールの説明より抜粋
※印は注釈としてあとから付けたもの
A client module encapsulates a portion of the application's overall functionality and typically represents a set of related concerns.
クライアントモジュールは
- アプリ全体の機能の一部をカプセル化する
- 関連する関心事を表す
It can include a collection of related components, such as application features, including user interface and business logic, or pieces of application infrastructure, such as application-level services for logging or authenticating users.
さらにクライアントモジュールは、関連するコンポーネント群を含むことができる
-
アプリケーション機能
- ユーザーインターフェース(※Viewのこと)
- ビジネスロジック(※ドメインのルール)
- アプリケーションのインフラ
- ロギングサービス
- ユーザ認証サービス
Modules are independent of one another but can communicate with each other in a loosely coupled fashion.
モジュールは互いに独立しているが、疎結合で互いに通信することもできる
(※あくまで依存せずにメッセージを送りあうというイメージか?)
Using a modular application design makes it easier for you to develop, test, deploy, and maintain your application.
モジュール化されたアプリは開発・テスト・デプロイ・保守を容易にする
おわりに
モジュールがいることで、わたしの中のDDDが一歩遠のいた
モジュールの立ち位置がわからない
PRISMライブラリを使いこなすことはできないのだろうか・・・
END
参考
WPFといえばこの御仁