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.4k
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
650
Other Decks in Programming
See All in Programming
Java 22 Overview
kishida
1
180
Anthropic Cookbook のおすすめレシピ
schroneko
7
920
Compose-View Interop in Practice (mDevCamp 2024)
stewemetal
0
130
Changed Rules: Architectures with Lightweight Stores
manfredsteyer
PRO
0
240
2 週間で Twitter Bot を作ってみた
contour_gara
0
350
エンターテイメント業界で利用されるAWS
demuyan
0
210
코틀린으로 멀티플랫폼 만들기
pangmoo
0
150
PHPの次期バージョンはこの時期どうなっているのか - Internalsの開発体制について - PHPカンファレンス小田原
youkidearitai
PRO
1
190
CA.swift19 恋するAIアプリ開発の裏側
oskmr
0
360
効率化に挑戦してみたらモバイル開発が少し快適になった話
ryunakayama
0
130
ADRを一年運用してみた/adr_after_a_year
hanhan1978
7
2.4k
検証も兼ねて個人開発でHonoとかと向き合った話
hanetsuki
0
880
Featured
See All Featured
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
244
20k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
2
3.4k
The Language of Interfaces
destraynor
151
23k
A Philosophy of Restraint
colly
197
16k
Making Projects Easy
brettharned
108
5.5k
How GitHub Uses GitHub to Build GitHub
holman
468
290k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
21
1.6k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
20
1.9k
Typedesign – Prime Four
hannesfritz
36
2.1k
Thoughts on Productivity
jonyablonski
58
3.8k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
17
1.4k
Debugging Ruby Performance
tmm1
70
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で書きやすいライブラリは未整備な状態。