Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
値オブジェクト / Value Object
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
OKUNOKENTARO
August 12, 2018
Technology
1.8k
5
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
値オブジェクト / Value Object
フロントエンド百物語で発表した資料です。
OKUNOKENTARO
August 12, 2018
More Decks by OKUNOKENTARO
See All by OKUNOKENTARO
トレタO/X アーキテクチャ移行記 Next.js App Router化への道のり / TORETA TECH UPDATE 1
okunokentaro
5
12k
Podcastを継続する技術 / refactoradio-240119
okunokentaro
1
230
Webアプリケーション設計の第一歩は ディレクトリの整理から / Encraft 1
okunokentaro
33
10k
JSONとJSON Schemaを改めて理解する / tokyo_study
okunokentaro
9
2.5k
それでもどうしてRecoilを使うのか / Harajuku.ts Meetup Recoil
okunokentaro
19
5.7k
TypeScriptは10年でこんなに進化しました / TechFeed Experts Night 11
okunokentaro
6
1.8k
Hasura.io RDBをサクサク作る方法はARやO/RMだけじゃなくなりました/hasura-io
okunokentaro
5
730
コードには型アノテーションよりも要件アノテーションを増やせ!/harajukuts2
okunokentaro
14
6.6k
10年と3ヶ月でWebサービスを作った話 / Piyogrammer Conference 2021
okunokentaro
2
1.1k
Other Decks in Technology
See All in Technology
ログラスのマルチプロダクトを 支える認証基盤 〜テナントごとに異なる統制とどう向き合うか〜
dada4386
3
330
Meet AgentCore Identity Consent Portal
hironobuiga
3
160
企業の現実世界をグラフで写し取る
sansantech
PRO
0
240
MCPゲートウェイを作って運用してわかったこと — Agent時代の権限管理の現在地
mtpooh
10
2.8k
BedrockとLambdaで作る リアルタイム進行型推理ゲーム
kawametho
0
160
大阪オフィスに Unitree Go2 がやってきたので Physical AI やってみた
dafujii
0
240
VS Code × GitHub Copilot での Fabric 開発
ryomaru0825
1
220
SDDの運用にめげずに向き合った話
sansantech
PRO
0
110
AIは爆速なのに、私が詰まっていた話 ― 音声入力と鳴くマスコットでボトルネックを削る
yama3133
0
320
人にやさしく、AIにやさしく、書き手を選ばないIaCのガードレール再考 / Rethinking IaC Guardrails for Humans and AI Alike
kohbis
5
2k
HacobuにおけるFDEとは/登壇資料(戸井田 裕貴)
hacobu
PRO
1
710
キャリアLT今日までそして明日から
kentapapa
1
140
Featured
See All Featured
My Coaching Mixtape
mlcsv
0
330
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
540
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
12k
Color Theory Basics | Prateek | Gurzu
gurzu
1
480
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
How GitHub (no longer) Works
holman
316
150k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
730
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
560
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
270
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.6k
Rails Girls Zürich Keynote
gr2m
96
14k
So, you think you're a good person
axbom
PRO
2
2.2k
Transcript
ΦϒδΣΫ τ "VH ϑϩϯ τΤϯ υඦޠ
ΦϒδΣΫ τͱ w %%% ʢυϝΠϯۦಈઃܭʣ Ͱड़ΒΕΔ֓೦ w +BWB4DSJQUʹTUSJOH OVNCFS CPPMFBOͱ͍͏
ϓϦ ϛςΟ ϒܕ͕͋Δ w TUSJOH OVNCFSΛ5ZQF4DSJQUͰͦͷ··ѻΘͣ ΦϒδΣΫ τͱͯ͠ఆٛ͢Δ͜ͱͰɺ ༷ʑͳΛࣝผՄೳʹ͢Δ
࣮ࡍͷҊ݅Ͱͷྫ w "2018/8"ͱ͍͏stringΛѻΘͣʹYearMonthܕͱ͢Δ w "-0900"ͱ͍͏stringΛѻΘͣʹTimeZoneܕͱ͢Δ w 1, 2, 3ͱ͍͏numberͰͳ͘UserIdܕͱ͢Δ w
Observable<[number, string, number, number]>ͩͱҙຯෆ໌͕ͩ Observable<[UserId, TimeZone, PageNumber, DisplayCount]> ͱఆٛͰ͖Δ
࣮ྫ export abstract class Value<T> { constructor(protected value: T) {
// } toString(): string { return this.value.toString(); } valueOf(): T { return this.value; } eq(other: Value<T>): boolean { return this.value === other.value; } }
export class TimeZone extends StringValue { TimeZone: ProhibitDuckTyping; static UTC():
TimeZone { return new TimeZone('+0000'); } /** * JST ͷ߹ɺ -540 Λ +0900 ʹม͢Δɻ */ static offsetToIsoTimeZone(offset: number): TimeZone { const min = Math.abs(offset); const isoTimeZone = [ `00${Math.floor(min / 60)}`.slice(-2), `00${min - Math.floor(min / 60) * 60}`.slice(-2), ].join(''); const sign = offset <= 0 ? '+' : '-'; return new TimeZone(`${sign}${isoTimeZone}`); } constructor(protected value: string) { super(value); assert(/^[+-]\d{4}/.test(value), `"${value}" ɺλΠϜκʔϯͷϑΥʔϚοτͰ͋Γ·ͤΜ`); } }
1SPIJCJU%VDL5ZQJOH w Ҋ݅Ͱੜ·ΕͨϫʔΫΞϥϯ υ ʢ5ZQF4DSJQUͷਖ਼ࣜͳٕज़ͷ໊শͰͳ͍ʣ w 5ZQF4DSJQU class A
{ value: string }ͱ class B { value: string }Λ ࠞಉͯ͠ѻ͏ ͜ͱ͕Ͱ͖Δ w ߏ͢ΔϓϩύςΟͷ໊শͱܕͱΈ߹Θ͕ͤಉ͡ͳΒಉ͡ΠϯλϑΣʔεͰ ͋ΔͱΈͳ͞ΕΔ
1SPIJCJU%VDL5ZQJOH w class A { value: string; A: ProhibitDuckTyping; }
class B { value: string; B: ProhibitDuckTyping; } ͷΑ ͏ʹ͢ΕϓϩύςΟ໊͕" #ͰҟͳΔͷͰผͷܕѻ͍Ͱ͖Δ w 1SPIJCJU%VDL5ZQJOH࣮࣭ export type ProhibitDuckTyping = void;