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
†黒魔術† と Annotation と AspectJ
Search
kaiinui
August 23, 2014
Technology
3
1.2k
†黒魔術† と Annotation と AspectJ
Annotation と AspectJ で楽しい黒魔術 (▰╹◡╹▰)
kaiinui
August 23, 2014
Tweet
Share
More Decks by kaiinui
See All by kaiinui
Black Magic in Java
kaiinui
1
540
API開発自動化と量産
kaiinui
0
430
Other Decks in Technology
See All in Technology
製造業向けIoTソリューション提案資料.pdf
haruki_uiru
0
270
試作とデモンストレーション / Prototyping and Demonstrations
ks91
PRO
0
130
Azure × MCP 入門
ry0y4n
8
1.8k
問 1:以下のコンパイラを証明せよ(予告編) #kernelvm / Kernel VM Study Kansai 11th
ytaka23
3
570
技術選定を突き詰める 懇親会LT
okaru
1
590
newmo の創業を支える Software Architecture と Platform Engineering
110y
5
540
encoding/json v2を予習しよう!
yuyu_hf
PRO
1
200
ユーザーコミュニティが海外スタートアップのDevRelを補完する瞬間
nagauta
1
190
250510 StepFunctionのテスト自動化始めました vol.1
east_takumi
1
230
Sleep-time Compute: LLM推論コスト削減のための事前推論
sergicalsix
1
130
VitePress & MCPでアプリ仕様のオープン化に挑戦する
hal_spidernight
0
120
Part2 GitHub Copilotってなんだろう
tomokusaba
2
820
Featured
See All Featured
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
160
15k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Build your cross-platform service in a week with App Engine
jlugia
231
18k
[RailsConf 2023] Rails as a piece of cake
palkan
54
5.5k
The Cost Of JavaScript in 2023
addyosmani
49
7.8k
Building an army of robots
kneath
305
45k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
120
52k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
24
2.7k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.4k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
331
21k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
47
2.7k
Transcript
†黒魔術† @_kaiinui
=
結論から? (▰╹◡╹▰)
@PotatoTip をつけるだけでトースト
Java の黒魔術: Annotation
Java の黒魔術: Annotation どうみても黒魔術
Java の黒魔術: Annotation Annotation as a code?
良さ? ・宣言的さ ・コードと「宣言」を分離出来る ・コードが短くなったり ・ミスを防止したり(@Nullable)
・ButterKnife の @InjectView ・Support Annotation の @NonNull ・AndroidAnnotations の @UiThread
・Rails の has_many 「する」と「である」を分ける
良い例: ButterKnife の @InjectView
する textView = (TextView) findViewById(R.id.text); である @InjectView(R.id.text) textView;
する runOnUiThread(new Runnable {...}); である @UiThread public void showToast() {..};
さて
Bring your own Annotation!
ツール • AspectJ • java.lang.annotation
初級編 Annotation を普通に使う(AspectJ じゃない)
1. Annotation をつくる(カンタン)
2. 黒魔術
3. 出来た
4. 完成 BananaKnife
中級編 AspectJ でアスペクトを織り込む
1. Annotation をつくる(カンタン)
2. AspectJ で黒魔術
@PotatoTip をつけるだけでトースト
AspectJ の良い例: Hugo
AspectJ の良い例: Hugo あまりに便利なので iOS 版もつくった kaiinui/KILogInjector
一言で? ・Annotation で @Hoge がついたメソッド、フィー ルド、クラスとかを弄れたりする ・AspectJ で処理をフックしてほげほげ、といった 処理がカンタンに書ける。 (▰╹◡╹▰)
きみだけのさいきょう @Annotation をつくろう!
「モデルと API 辛い」周りの話がしたかった あと自分で作るとかどうでもいいので既にある Annotation をまず使おう (▰╹◡╹▰) 最後に