Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
TypeScriptでDDD〜RepositoryとEntity編〜
Search
Shinse Tanaka
April 30, 2017
Programming
5
3.5k
TypeScriptでDDD〜RepositoryとEntity編〜
We Are JavaScripters! @6th
https://wajs.connpass.com/event/54667/
Shinse Tanaka
April 30, 2017
Tweet
Share
More Decks by Shinse Tanaka
See All by Shinse Tanaka
PrimeNGという選択肢について
mrdshinse
0
700
Other Decks in Programming
See All in Programming
Spring gRPC について / About Spring gRPC
mackey0225
0
220
Pythonでもちょっとリッチな見た目のアプリを設計してみる
ueponx
1
570
PHP ステートレス VS ステートフル 状態管理と並行性 / php-stateless-stateful
ytake
0
100
負債になりにくいCSSをデザイナとつくるには?
fsubal
10
2.4k
Amazon ECS とマイクロサービスから考えるシステム構成
hiyanger
2
560
『品質』という言葉が嫌いな理由
korimu
0
160
法律の脱レガシーに学ぶフロントエンド刷新
oguemon
5
740
Open source software: how to live long and go far
gaelvaroquaux
0
640
Software Architecture
hschwentner
6
2.1k
Conform を推す - Advocating for Conform
mizoguchicoji
3
690
『GO』アプリ バックエンドサーバのコスト削減
mot_techtalk
0
140
Ruby on cygwin 2025-02
fd0
0
150
Featured
See All Featured
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
7
630
Mobile First: as difficult as doing things right
swwweet
223
9.3k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
The Pragmatic Product Professional
lauravandoore
32
6.4k
Making Projects Easy
brettharned
116
6k
Navigating Team Friction
lara
183
15k
How to Ace a Technical Interview
jacobian
276
23k
Designing for Performance
lara
604
68k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
33
2.8k
Designing for humans not robots
tammielis
250
25k
Faster Mobile Websites
deanohume
306
31k
Producing Creativity
orderedlist
PRO
344
39k
Transcript
TypeScriptでDDD RepositoryとEntity編
自己紹介 ・不動産Techで働いてます。 ・Java/Scala/Ruby + ちょっとjs ・Web↔SI双方の技術を高めたい ・Node.js / TypeScriptでDDDしてみたい モチベーション
@mrdShinse @Shinse Tanaka
None
話すこと
https://github.com/mrdShinse/eve-linebot
ディレクトリ構成 ./app/application →アプリ起動時の設定やドメイン処理に 必要な前処理などを書く。 今回だとExpress.jsの起動。 ./domain →アプリケーションが解決したい問題や 業務の処理を書く。 ./infra →各レイヤーを実装するために必要な
具体的処理が書かれる。 今回だとMongo関係の処理。
ドメインとライブラリ依存を切り離したい
domainパッケージ
エンティティの定義 User →Entityとして定義。 nameはValueObject として定義する。
リポジトリ用読み書きインターフェース
ユーザーリポジトリの定義
domainパッケージにはmongoの処理を入れない! 続いてinfraパッケージ
Mongoリポジトリ共通親クラス
ユーザーリポジトリ
いい感じに
所感 ・TypeScriptのGenericsはいい ・TypeScriptでちゃんと設計してあげる事で・・・ (jsでそれ必要?という議論はあるがw) ・エンジニアの技術力の差を吸収することができる。 ・仕様の変更や依存ライブラリの変更に強くなる ・結果として、Node.jsで業務寄りなプログラムを書きやすくなる。 ・mongooseだとdomainとinfraの切り分けはできない・・・?``` ・DDDで書きやすいライブラリは未整備な状態。