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
Understanding the interface
Search
minionsobe
June 21, 2017
Technology
2.2k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Understanding the interface
CA.go 20170621
minionsobe
June 21, 2017
Other Decks in Technology
See All in Technology
会社説明資料
persolserverworks
0
9.8k
AIにシークレットを見せない、WSL2で安全な開発環境
yazm
0
300
エンタメ企業のM&Aを支えるデータ基盤 ― 統合から店舗のリアルタイム分析まで / Data Engineering Summit 2026
genda
0
170
触りたくないデータに、どう触るか AI時代のRBACアクセスガバナンス
ivry_presentationmaterials
0
260
PagerDuty Tech Hub-鳴らすけれど、人は動かない
ezaki
0
170
SAENM ~Jupyterで残すPoCの試行錯誤、未来の自分と仲間を助ける記録!~
terapyon
0
110
『SAR衛星データ解析入門』のご紹介とその応用
syuchimu
0
120
その Valkey 使いこなしていますか?
onk
PRO
5
1.5k
Classmethod Company Deck
satoshi7
1
680
⾮構造化データを価値に変える AI エージェント基盤とその組織
ivry_presentationmaterials
0
190
Railsで挑む大量データ永続化 〜600億件を永続化するための設計とボトルネックとの戦い〜
occhi
1
580
PHPカンファレンス関西の招待状 / Invitation to PHP Conference Kansai
ykanoh
0
110
Featured
See All Featured
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
1k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
410
A Tale of Four Properties
chriscoyier
163
24k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
280
We Are The Robots
honzajavorek
0
400
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.2k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.6k
The Invisible Side of Design
smashingmag
301
52k
Odyssey Design
rkendrick25
PRO
2
870
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
410
Speed Design
sergeychernyshev
33
2.2k
Transcript
understanding the interface CA.go - 2017-06-21 @oliverminion(sobecanada)
Huang Yumin Oliver @oliverminion - - at AmebaOwnd (CyberAgent, inc.)
- - as Server Side Engineer (System Administorator) - - for 2+ years (golang) - - has Cooker interface
Agenda - - What is a Go interface ? -
- Why using an interface ? - - Go interface in Ownd ! - - Where is the reflect ?
Go interface
abstract types concrete types
concrete types int8 int16 int32 int64 Memory Layout の 定義
Using in the Method
abstract types fmt.Stringer io.Reader io.Writer Behaviour(動作) の 定義 Using in
the Method receiver ?
interface{}
“interface{} says nothing.” - Rob Pike in his Go Proverbs
Why using an interface ? Generic Algorithm Interception Point Hiding
Implementation Detail
Why using an interface ? Generic Algorithm
sortable interface Sort Algorithms Interface - data が Interface の
methods を 持っていれば - Sort Algorithms が使える - Sort Algorithm はdata の型に依 存しない
Why using an interface ? Hiding Implementation Detail
Hide Implementation Detail Adv. - - API から 実装を切り離せる -
実装(implementation)の追加、変更、etc が簡単に行える
Hide Implementation Detail Context context context.Context
Hide Implementation Detail Context emptyCtx cancelCtx valueCtx timerCtx
Why using an interface ? Interception Point
Interception point(s)
Chainning interface io.Copy *gzip.Reader *base64.Decoder *strings.Reader *os.File `44GT44KM44KSRGVjb2Rl44GX44Gf5pa544GvU3Bva2VI YW5k44Gn5oyZ5omL44GX44Gm44GP44Gg44GV44GE` “Decodeした方はSpokeHandで挙手
してください”
Why using an interface ? Generic Algorithm Interception Point Hiding
Implementation Detail
Go interface in Ownd
contentBlock.Block
Block in Ownd Block block
Generic Algorithm Block imgBlock twitterBlock htmlBlock textBlock videoBlock
Hide Implementation Detail Block imgBlock htmlBlock textBlock videoBlock ? Block
twitterBlock
Chainning interface MarshalHtml GoogleAMP imgBlock, textBlock defaultBlock(s) domain Raw Data
type assertions
type assertions
type assertions Concrete Type の比較!
type assertions better way! Abstract Type の比較!
type assertions type check は interfaceで; - - fmt.Stringer -
json.Marshal/Unmarshal - ...
“The bigger the interface, the weaker the abstraction” - Rob
Pike in his Go Proverbs
Where is the reflect ?
type assertions (*partially)
“Reflection is never clear” - Rob Pike in his Go
Proverbs reflect は 次回またのご機会があります時に ... - Next Time...
Huang Yumin Oliver @oliverminion - - at AmebaOwnd (CyberAgent, inc.)
- - as Server Side Engineer (System Administorator) - - for 2+ years (golang) - - has Cooker interface
ご静聴ありがとうございました Thanks CA.go - 2017-06-21 @oliverminion(sobecanada)