Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
TypeScriptでDDD〜RepositoryとEntity編〜
Shinse Tanaka
April 30, 2017
Programming
5
2.6k
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
490
Other Decks in Programming
See All in Programming
NieR Re[in]carnationにおけるUnityアニメーション活用術
applibot
1
960
書籍『良いコード/悪いコードで学ぶ設計入門』でエンジニアリングの当たり前を変える
minodriven
3
1.2k
カラーミーショップは私たちが作っています
kenchan
0
130
Oculus Interaction SDK 概説 / xrdnk-caunity-LT4
xrdnk
0
300
Viteはいいぞ/Vite is Good
dojineko
1
110
職場にPythonistaを増やす方法
soogie
0
330
テスト設計技法をなぜ&どのように使うのか体験しよう!
imtnd
0
540
Node.js 最新動向 TFCon 2022
yosuke_furukawa
PRO
6
3k
マイクロサービスプラットフォーム向け負荷試験基盤の初期リリースを終えた話
yuyu_hf
PRO
1
500
Let's build components, not layers
thombergs
1
260
LOWYAの信頼性向上とNew Relic
kazumax55
4
370
LegalForceの契約データを脅かすリスクの排除と 開発速度の向上をどうやって両立したか
aibou
0
640
Featured
See All Featured
From Idea to $5000 a Month in 5 Months
shpigford
372
44k
How GitHub Uses GitHub to Build GitHub
holman
465
280k
Stop Working from a Prison Cell
hatefulcrawdad
261
17k
jQuery: Nuts, Bolts and Bling
dougneiner
56
6.4k
How New CSS Is Changing Everything About Graphic Design on the Web
jensimmons
212
11k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
181
15k
The Illustrated Children's Guide to Kubernetes
chrisshort
14
35k
Learning to Love Humans: Emotional Interface Design
aarron
261
37k
Faster Mobile Websites
deanohume
294
28k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
4
670
Web development in the modern age
philhawksworth
197
9.3k
The MySQL Ecosystem @ GitHub 2015
samlambert
238
11k
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で書きやすいライブラリは未整備な状態。