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エージェントのキホンから学ぶ「エージェンティックコーディング」実践入門
masahiro_nishimi
3
230
メルカリのリーダビリティチームが取り組む、AI時代のスケーラブルな品質文化
cloverrose
2
510
Data-Centric Kaggle
isax1015
2
760
CSC307 Lecture 08
javiergs
PRO
0
660
Amazon Bedrockを活用したRAGの品質管理パイプライン構築
tosuri13
4
230
IFSによる形状設計/デモシーンの魅力 @ 慶應大学SFC
gam0022
1
290
CSC307 Lecture 05
javiergs
PRO
0
490
なるべく楽してバックエンドに型をつけたい!(楽とは言ってない)
hibiki_cube
0
140
コマンドとリード間の連携に対する脅威分析フレームワーク
pandayumi
1
440
AI時代のキャリアプラン「技術の引力」からの脱出と「問い」へのいざない / tech-gravity
minodriven
20
6.4k
Spinner 軸ズレ現象を調べたらレンダリング深淵に飲まれた #レバテックMeetup
bengo4com
1
230
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
470
Featured
See All Featured
Claude Code のすすめ
schroneko
67
210k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
62
49k
Navigating Team Friction
lara
192
16k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.1k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
400
How GitHub (no longer) Works
holman
316
140k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
0
170
How To Stay Up To Date on Web Technology
chriscoyier
791
250k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
370
AI Search: Where Are We & What Can We Do About It?
aleyda
0
6.9k
We Have a Design System, Now What?
morganepeng
54
8k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
62
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で書きやすいライブラリは未整備な状態。