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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
600
API開発自動化と量産
kaiinui
1
460
Other Decks in Technology
See All in Technology
20年以上続く PHP 大規模プロダクトを Kubernetes へ ── クラウド基盤刷新プロジェクトの4年間
oogfranz
PRO
0
160
Blue/Green Deployment を用いた PostgreSQL のメジャーバージョンアップ
kkato1
0
100
Astro Islandsの 内部実装を 「日本で一番わかりやすく」 ざっくり解説!
knj
0
210
モジュラモノリス導入から4年間の総括:アーキテクチャと組織の相互作用について / Architecture and Organizational Interaction
nazonohito51
3
1.5k
Cortex Code CLI と一緒に進めるAgentic Data Engineering
__allllllllez__
0
630
Copilot 宇宙へ 〜生成AIで「専門データの壁」を壊す方法〜
nakasho
0
150
DDD×仕様駆動で回す高品質開発のプロセス設計
littlehands
5
2.1k
中央集権型を脱却した話 分散型をやめて、連邦型にたどり着くまで
sansantech
PRO
1
200
How to install a gem
indirect
0
230
Kiroで見直す開発プロセスとAI-DLC
k_adachi_01
0
120
"作る"から"使われる"へ:Backstage 活用の現在地
sbtechnight
0
240
事例から紐解くSHIFT流QA支援 ~大規模プロジェクトの品質管理支援、QA組織立ち上げ~ / 20260320 Nozomu Koketsu
shift_evolve
PRO
0
130
Featured
See All Featured
Unsuck your backbone
ammeep
672
58k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
140
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
160
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
92
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
1.9k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
300
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
61
43k
Mind Mapping
helmedeiros
PRO
1
130
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.4k
Designing for Performance
lara
611
70k
The Curse of the Amulet
leimatthew05
1
10k
The Curious Case for Waylosing
cassininazir
0
270
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 をまず使おう (▰╹◡╹▰) 最後に