Movatterモバイル変換


[0]ホーム

URL:


公開日:変更日: Download PDF

autoscale: true

Faao - ドメイン駆動設計で作るGitHub Issue Client -


自己紹介

アイコン right


過去に作ったやつ


github-reader fitGitHubReader fit


github-issue-teev fit


Faao


fit, movie faao


Faao - Feature


目的


規模感(2017-07-03現在)

✈ cloc src       212 text files.       208 unique files.         4 files ignored.github.com/AlDanial/cloc v 1.72  T=1.31 s (159.3 files/s, 12962.9 lines/s)-------------------------------------------------------------------------------Language                     files          blank        comment           code-------------------------------------------------------------------------------TypeScript                     165            859            478           8487JSON                             7              1              0           6189CSS                             34            120             60            728Markdown                         2              3              0              6-------------------------------------------------------------------------------SUM:                           208            983            538          15410-------------------------------------------------------------------------------`

作戦


DDD

ちゃんとモデリング[^モデル]をやる

[^モデル]: ここでいうモデルはEntityとかValue Objectを含めたドメイン上のモデルクラス


クライアントサイドDDD


モデリング

多くの処理(ユースケース)は

AppUserGitHubSettingを使って 〜〜 する

のようになることが分かってくる


遠回りのモデリング


遠回りの例

fit right, User Profile Image

interface GitHubSetting {      id: Identifier<GitHubSetting>;      token: string;      apiHost: string;      webHost: string;      // ADD?      avatarImageURL?: string;}

遠回りの例 -> GitHubUser

fit right, Relationship

interface GitHubSetting {      id: Identifier<GitHubSetting>;      token: string;      apiHost: string;      webHost: string;      // Relationship      gitHubUserId?: Identifier<GitHubUser>;}

^ [GitHubUser]%0A[GitHubUser|%0A%09[id]%0A [profile| %0A %09[avatarImageURL]%0A ]%0A %0A]%0A>


遠回りのモデリング

right,fit, GitHubSetting.png


ドメインモデル -> 永続化


Hard repository


このアプリの永続化してる部分


fill eizokuka.png


永続化


[fit] 永続化はRepositoryの仕事だけど

fit, right, toJSON, fromJSON


[fit] ドメインモデルは永続化(技術的制約)を知らずに済むか

Patterns, Principles, and Practices of Domain-Driven Designより


fit PPPDDDから引用

^ マッピングできるタイプ


fit PPDDDから引用

^ JSONをそのまま保存できるもの + 妥協あり(ドメインが知っている)


fit PPPDDDから引用

^ Mementoパターンでのスナップショット


妥協あり/なしの永続化

// 駄目なケースlet id = 0;class User {   constructor(){      this.id = id++   }}

どちらにしてもドメインは軽くは永続化を意識する

// OKなケースclass User {   constructor({ id }){      this.id = id;   }}

スナップショットからの復元

right,fit, GitHubSetting.png


Repository


UseCase


UseCase


ユースケース図

一点、注意が必要なのは、ユースケース記述とユースケース図は異なるということです。 このガイドラインはユースケース記述のガイドラインです。UseCaseの再利用性 - yoskhdia’s diary


Living Documentation

right, cover


知識の共有

KnowledgeにはGenericなものとSpecificなものがある。会社やチーム、プロダクトにおけるSpecificな知識には次のような問題が生まれやすい


Living Documentation


#LivingDocumentationのコア原則


具体的な問題と対策


Living Documentationの4つのステップ

  1. 何処かに保存されたデータの範囲を選択
  2. データをドキュメントの目的に沿ってフィルター
  3. フィルターした結果、各データのサブセットを抽出
  4. ドキュメントを生成するためのフォーマットへ変換


守られないルールは価値がない


守られないルールは価値がない


[fit] 例) ルール: ドメインはインフラ(repository)を参照してはいけない

dependency-cruiserを使ってルールをコード化し自動チェックする

{  "forbidden": [    {      "name": "domain-not-to-depend-on-infra",      "comment": "Don't allow dependencies from domain to infra",      "severity": "error",      "from": { "path": "^src/domain" },      "to":   { "path": "^src/infra"  }    }}

破れないルールは価値を鈍化させる


破れないルールは価値を鈍化させる


Living Documentation

Living Diagram


ユースケース図のLiving Diagram

fit, right, usecase of faao


Living Diagramの使いみち


2/3のバグはカバレッジを上げると見つかる

A majority of the production failures (77%) can be reproduced by a unit test.--Simple testing can prevent most critical failures | the morning paper


[fit] Living Documentationはドキュメンテーションをコード化する

詳しくは本を読んで


Almin

inline, Almin.js


Almin


fit, inline saikyo-framework.png

ぼくのかんがえたさいきょうのうぇぶあぷりけーしょんふれーむわーく - YAPC Asia 2011


TypeScript


Jest


Jest


Jest色々


メタテスト


GraphQL


GitHub API trap


Philosophy


Debuggablity - 状態


Debuggablity - データ


Debuggability - イベント

right, fit, debug


まとめ


参考


[8]ページ先頭

©2009-2025 Movatter.jp