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.7k
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
780
Other Decks in Programming
See All in Programming
生成AIを使ったコードレビューで定性的に品質カバー
chiilog
1
310
nilとは何か 〜interfaceの構造とnil!=nilから理解する〜 / Understanding nil in Go Interface Representation and Why nil != nil
kuro_kurorrr
2
1.1k
浮動小数の比較について
kishikawakatsumi
0
340
エージェント開発初心者の僕がエージェントを作った話と今後やりたいこと
thasu0123
0
160
PJのドキュメントを全部Git管理にしたら、一番喜んだのはAIだった
nanaism
0
210
2025年の活動の振り返り
hideg
0
110
CSC307 Lecture 09
javiergs
PRO
1
850
モジュラモノリスにおける境界をGoのinternalパッケージで守る
magavel
0
1.2k
AI時代でも変わらない技術コミュニティの力~10年続く“ゆるい”つながりが生み出す価値
n_takehata
2
440
AWS re:Invent 2025参加 直前 Seattle-Tacoma Airport(SEA)におけるハードウェア紛失インシデントLT
tetutetu214
2
130
Lambda のコードストレージ容量に気をつけましょう
tattwan718
0
200
AI時代の認知負荷との向き合い方
optfit
0
180
Featured
See All Featured
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.2k
The World Runs on Bad Software
bkeepers
PRO
72
12k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
180
Automating Front-end Workflow
addyosmani
1371
200k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
21k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
450
How STYLIGHT went responsive
nonsquared
100
6k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.1k
Leo the Paperboy
mayatellez
4
1.5k
Crafting Experiences
bethany
1
65
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
24k
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で書きやすいライブラリは未整備な状態。