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
770
Other Decks in Programming
See All in Programming
今こそ知るべき耐量子計算機暗号(PQC)入門 / PQC: What You Need to Know Now
mackey0225
3
260
Patterns of Patterns
denyspoltorak
0
450
TerraformとStrands AgentsでAmazon Bedrock AgentCoreのSSO認証付きエージェントを量産しよう!
neruneruo
4
2.4k
愛される翻訳の秘訣
kishikawakatsumi
3
370
PostgreSQLで手軽にDuckDBを使う!DuckDB&pg_duckdb入門/osc25hi-duckdb
takahashiikki
0
240
LLM Observabilityによる 対話型音声AIアプリケーションの安定運用
gekko0114
2
130
LLM Çağında Backend Olmak: 10 Milyon Prompt'u Milisaniyede Sorgulamak
selcukusta
0
150
HTTPプロトコル正しく理解していますか? 〜かわいい猫と共に学ぼう。ฅ^•ω•^ฅ ニャ〜
hekuchan
2
640
React 19でつくる「気持ちいいUI」- 楽観的UIのすすめ
himorishige
11
5.2k
Python札幌 LT資料
t3tra
7
1.1k
CSC307 Lecture 04
javiergs
PRO
0
630
ゆくKotlin くるRust
exoego
1
200
Featured
See All Featured
Code Review Best Practice
trishagee
74
19k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
140
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
1
420
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
100
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
330
Digital Ethics as a Driver of Design Innovation
axbom
PRO
0
140
Technical Leadership for Architectural Decision Making
baasie
0
200
Code Reviewing Like a Champion
maltzj
527
40k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
230
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.9k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.3k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
49
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で書きやすいライブラリは未整備な状態。