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
690
Other Decks in Programming
See All in Programming
エラーレスポンス設計から考える、0→1開発におけるGraphQLへの向き合い方
bicstone
5
1.5k
Architecture Decision Record (ADR)
nearme_tech
PRO
1
680
マルチモジュールにおけるテスト最適化
fxwx23
0
210
Ruby Parser progress report 2024
yui_knk
2
230
LangGraphでのHuman-in-the-Loopの実装
os1ma
3
1.1k
労務ドメインを快適に開発する方法 / How to Comfortably Develop in the Labor Domain
yuki21
1
250
The Sequel to a Dream of Ruby Parser's Grammar
ydah
1
220
Patched fetch did not work
quramy
3
180
GenU導入でCDKに初挑戦し、悪戦苦闘した話
hideg
0
160
How to Break into Reading Open Source
kaspth
2
210
マイグレーションコード自作して File-Based Routing に自動移行!! ~250 ページの歴史的経緯を添えて~
cut0
1
260
長期運用プロダクトの開発速度を維持し続けるためのリファクタリング実践例
wataruss
8
2.7k
Featured
See All Featured
Being A Developer After 40
akosma
84
590k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
89
16k
Producing Creativity
orderedlist
PRO
340
39k
Thoughts on Productivity
jonyablonski
66
4.2k
Facilitating Awesome Meetings
lara
49
5.9k
Designing on Purpose - Digital PM Summit 2013
jponch
114
6.8k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
0
97
Build your cross-platform service in a week with App Engine
jlugia
228
18k
The Invisible Customer
myddelton
119
13k
Testing 201, or: Great Expectations
jmmastey
36
7k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
278
13k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
166
48k
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で書きやすいライブラリは未整備な状態。