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
Inversion of Control in Javascript
Search
Michael Yockey
April 19, 2017
Programming
98
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Inversion of Control in Javascript
Michael Yockey
April 19, 2017
More Decks by Michael Yockey
See All by Michael Yockey
Background Procrastination
yock
0
74
Other Decks in Programming
See All in Programming
HTML-in-Canvasで作る未来のWeb UI表現
clockmaker
5
5.1k
KiroのSpecで「五目並べ」を作ってみる
satoshi256kbyte
1
380
UPDATE をやめる — EF Core でマスタをバージョン管理する
panda728
PRO
0
1.2k
FactoryBotをやめればRSpecは速くなるのか?
yuta_onishi_97
0
610
Everything will be SERVERLESS — 信じて運用した10年の経験値 / Everything Will be Serverless — Lessons Learned from 10 Years of Operational Experience
seike460
PRO
1
1.1k
Domain-Driven Transformation
hschwentner
2
2.3k
現場と育てるRailsモデリング 〜Spreadsheetから始めたモデル設計〜
siroemk
2
610
JIS keyboard support in Omarchy
lef237
0
120
作れる、でも消せるか?──安全に「枯らして消す」機能削除術 / Drain, Then Delete
chobishiba
2
760
iOS 27でニュースアプリはどう変わる!? 〜日経電子版の新機能対応と、開発事例から〜
lynnswap
7
13k
PumaからFalconに移行したRailsアプリケーションでの実践
falcon8823
0
170
[JA] Domain Modeling with Vanilla Rails: 「操作」から再考するRailsの設計論
yasaichi
2
350
Featured
See All Featured
It's Worth the Effort
3n
188
29k
Amusing Abliteration
ianozsvald
1
350
Code Review Best Practice
trishagee
74
20k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
2
330
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
2
410
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
33
5.2k
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
2
2.9k
We Have a Design System, Now What?
morganepeng
55
8.4k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
360
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.3k
How to Think Like a Performance Engineer
csswizardry
28
2.9k
Transcript
Dependency Injection or How I Couldn’t Think of a Better
Title
export const search = (keyword) => { const repo =
new Repo(); return repo.find((record) => { return !!record.text.match(keyword); }); }
import { search } from ‘./search’; app.get(“/search”, req, res) {
const keyword = req.params.keyword; const record = search(keyword); res.send(record); }
import { search } from ‘./search’; describe(‘search’, () => {
it(‘returns a record’,() => { const actual = search(‘test’); assert.ok(actual); }); });
import { search } from ‘./search’; describe(‘search’, () => {
it(‘returns a record’,() => { const actual = search(‘test’); // error! assert.ok(actual); }); });
Mike Yockey Sparkbox @myockey
Dependency Management • Layered Dependencies • Inversion of Control
export const search = (keyword) => { const repo =
new Repo(); return repo.find((record) => { return !!record.text.match(keyword); }); }
export const search = (keyword, repo) => { return repo.find((record)
=> { return !!record.text.match(keyword); }); }
import { search } from ‘./search’; class DummyRepo { find(callback)
{ return ‘ok’; } } describe(‘search’,() => { it(‘returns a record’,() => { const actual = search(‘test’, new DummyRepo); assert.ok(actual); }); });