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
Mockable UserDefaults with Duck typing
Search
417.72KI
June 18, 2019
Programming
0
830
Mockable UserDefaults with Duck typing
417.72KI
June 18, 2019
Tweet
Share
More Decks by 417.72KI
See All by 417.72KI
iTunes・おぼえていますか〜ScriptingBridge今昔物語〜
417_72ki
1
23
The history of entry-point in iOS app Development
417_72ki
0
360
R.swift to Asset Symbols
417_72ki
0
250
Refactor with using `available` and `deprecated`
417_72ki
3
600
CLIツールにSwift Concurrencyを適用させようとしている話
417_72ki
3
390
CI with Danger-Swift
417_72ki
1
200
Graduation from Playground beginner
417_72ki
3
890
Trap Questions in Java and Obj-C
417_72ki
1
270
ダックタイピングとidでUserDefaultsをモック化する
417_72ki
2
2.5k
Other Decks in Programming
See All in Programming
Contemporary Test Cases
maaretp
0
140
macOS でできる リアルタイム動画像処理
biacco42
9
2.4k
リアーキテクチャxDDD 1年間の取り組みと進化
hsawaji
1
220
みんなでプロポーザルを書いてみた
yuriko1211
0
260
as(型アサーション)を書く前にできること
marokanatani
10
2.7k
レガシーシステムにどう立ち向かうか 複雑さと理想と現実/vs-legacy
suzukihoge
14
2.2k
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
1
100
Compose 1.7のTextFieldはPOBox Plusで日本語変換できない
tomoya0x00
0
190
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
100
Kaigi on Rails 2024 〜運営の裏側〜
krpk1900
1
230
ふかぼれ!CSSセレクターモジュール / Fukabore! CSS Selectors Module
petamoriken
0
150
WebフロントエンドにおけるGraphQL(あるいはバックエンドのAPI)との向き合い方 / #241106_plk_frontend
izumin5210
4
1.4k
Featured
See All Featured
Docker and Python
trallard
40
3.1k
Art, The Web, and Tiny UX
lynnandtonic
297
20k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Designing the Hi-DPI Web
ddemaree
280
34k
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
Testing 201, or: Great Expectations
jmmastey
38
7.1k
Designing Experiences People Love
moore
138
23k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
Scaling GitHub
holman
458
140k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Transcript
.PDLBCMF6TFS%FGBVMUT XJUI %VDLUZQJOH QPUBUPUJQT
struct Me { let name = "Takuhiro Muta" let aka
= "417.72KI" let experienceYears = 5 let company = "iRidge inc." let twitter = "417_72ki" let qiita = "417_72ki" let gitHub = "417-72KI" let products = [ "BuildConfig.swift", "MockUserDefaults", ] } TFMGEFTDSJQUJPO
%VDL5ZQJOH
%VDL5ZQJOH w 0OFPGUIFNFUIPETUPJNQMFNFOU QPMZNPSQIJTN w 6TFEJOEZOBNJDMBOHVBHFT FH3VCZ 1ZUIPO w
0CKFDUTTVJUBCJMJUZJTEFUFSNJOFECZUIF QSFTFODFPGDFSUBJONFUIPETBOE QSPQFSUJFT w /PUPCKFDU`TPXOUZQF
r%BWF5IPNBT l*GJUXBMLTMJLFBEVDLBOERVBDLTMJLFB EVDL JUNVTUCFBEVDLz
%VDL5ZQJOH class Duck: def walk(self): print("Duck walking") def quack(self): print("Quack!!")
class Dog: def walk(self): print("Dog walking") def bark(self): print("Bark!!") def walk_and_quack(animal): animal.walk() animal.quack()
%VDL5ZQJOH class Duck: def walk(self): print("Duck walking") def quack(self): print("Quack!!")
class Dog: def walk(self): print("Dog walking") def bark(self): print("Bark!!") def walk_and_quack(animal): animal.walk() animal.quack()
%VDL5ZQJOH class Duck: def walk(self): print("Duck walking") def quack(self): print("Quack!!")
class Dog: def walk(self): print("Dog walking") def bark(self): print("Bark!!") def walk_and_quack(animal): animal.walk() animal.quack()
%VDL5ZQJOH class Duck: def walk(self): print("Duck walking") def quack(self): print("Quack!!")
class Dog: def walk(self): print("Dog walking") def bark(self): print("Bark!!") def walk_and_quack(animal): animal.walk() animal.quack()
%VDL5ZQJOH walk_and_quack(Duck()) # Duck walking # Quack!! walk_and_quack(Dog()) # Dog
walking # AttributeError: 'Dog' object has # no attribute 'quack'
*O0CK$ @interface Duck: NSObject - (void)walk; - (void)quack; @end @implementation
Duck - (void)walk { NSLog(@"Duck walking"); } - (void)quack { NSLog(@"Quack!!"); } @end void walkAndQuack(id animal) { [animal walk]; [animal quack]; }
*O0CK$ @interface Duck: NSObject - (void)walk; - (void)quack; @end @implementation
Duck - (void)walk { NSLog(@"Duck walking"); } - (void)quack { NSLog(@"Quack!!"); } @end void walkAndQuack(id animal) { [animal walk]; [animal quack]; }
*O0CK$ @interface Duck: NSObject - (void)walk; - (void)quack; @end @implementation
Duck - (void)walk { NSLog(@"Duck walking"); } - (void)quack { NSLog(@"Quack!!"); } @end void walkAndQuack(id animal) { [animal walk]; [animal quack]; }
*O0CK$ walkAndQuack([Duck new]); // Duck walking // Quack!! walkAndQuack([Dog new]);
// Dog walking // unrecognized selector sent to instance
)PXUPNPDL 6TFS%FGBVMUT
r%BWF5IPNBT l*GJUXBMLTMJLFBEVDLBOERVBDLTMJLFB EVDL JUNVTUCFBEVDLz
l*GJUTBWFTPCKFDUTMJLF6TFS%FGBVMT BOEMPBETPCKFDUTMJLF6TFS%FGBVMUT JUNVTUCF6TFS%FGBVMUTz
%FpOFBMMNFUIPETJO /46TFS%FGBVMUT
%FpOFBMMNFUIPETJO /46TFS%FGBVMUT /PUFYUFOE/46TFS%FGBVMUT
*NQMFNFOU
%FpOFFYUFOTJPOUPVTFJU BT/46TFS%FGBVMUT
%FpOFFYUFOTJPOUPVTFJU BT/46TFS%FGBVMUT
%FpOFFYUFOTJPOUPVTFJU BT/46TFS%FGBVMUT ⁉
None
5IBOLZPV IUUQTHJUIVCDPN,*.PDL6TFS%FGBVMUT