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
100
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
Transcript
10 slides
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); }); });
More Decks by Michael Yockey
See All by Michael Yockey
Background Procrastination
yock
0
80
Other Decks in Programming
See All in Programming
R言語プログラミング
profjoesuzuki
0
130
Enforcing Your Architecture with Unit Tests in the AI Era (Swift Connection X)
steliosf
PRO
1
200
How SRE Grew Out of Server-Side Work and Became the Team's Own / サーバサイドから始まったSREを チームに渡すまで
maaaato
1
370
AWS CDKを理解するために公式の定義を深掘って解説してみる / Understanding AWS CDK by Digging into Its Official Definition
akihisaikeda
3
360
Going Full Circle with Virtual Graphs and Relational Databases
michaelsimons
1
120
例外からRich Errorsまで Kotlinエラーハンドリングの進化を読み解く
shiita0903
0
250
はじめてのKubernetesコントリビューション
nasa9084
0
330
AIが実装を担う時代の「技術設計」と「チームマネジメント」
kamina_zzz
2
470
コード生成時代のAPI定義を支えるRequest Spec移行
pvcresin
0
320
joyful-journey-spring-boot.pdf
hollycummins
0
130
Crash Auto Pipelines
veronikapj
1
460
仕様駆動開発入門 (何を作るかを先に決めて渡す) | 目指せ Kiro マスター 05
inariku
PRO
3
250
Featured
See All Featured
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
70
69k
Technical Leadership for Architectural Decision Making
baasie
4
660
Large-scale JavaScript Application Architecture
addyosmani
516
110k
HDC tutorial
michielstock
2
1k
Building the Perfect Custom Keyboard
takai
2
970
Statistics for Hackers
jakevdp
799
230k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.3k
Building Flexible Design Systems
yeseniaperezcruz
330
41k
Amusing Abliteration
ianozsvald
1
400
The Art of Programming - Codeland 2020
erikaheidi
57
15k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
1
680
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
620