Designing Auto Generated Codes 17 Nov 2015 Roppongi.aar #2 @kikuchy
Who am I • Hiroshi Kikuchi (@kikuchy) • Belonging to , inc , Working on , inc (mixi group) • Making Dating App for Android • Strict review OJISAN
APT made our work reduced!! So, you use APT, and be happy!! ＼＼\\٩( 'ω' )و //／／
… I was going to talk about like that, but
Oh, you are already using APT.
So, I ll talk about
Designing Auto Generated Codes
What is the best way to use Generated Code in our project? Please consider and discuss.
The Problem Make Us Wakeful
Case 1 (/2)
If you make an awesome library hiding generated codes… // Fields @ExecuteSomething String foo; // Executor class “ThisClass$$Executor” is generated. // My library loads executor class automatically! AwesomeLibrary.execute(this);
Alice changes Naming Rule of Generated Class. ex) (ClassName)$$Executor -> (ClassName)$$Doer
< Hey, I obfuscated your code! Proguard @ Production Build
Case 2 (/2)
If you make awesome proguard-safe library… // Fields @ExecuteSomething String foo; // Executor class “ThisClassExecutor” is generated. // There are no reflection, no ClassNotFoundException!! new ThisClassExecutor().execute(this);
Bob often asks you What s the name of Generated Classes and methods and constructor arguments and interfaces will use in Generated Code blablabla…
Compare patterns Butter Knife pattern Dagger2 pattern (hiding generated codes) (no reﬂection) How to load generated Library dose everything Developers have to import codes Proguard conﬁguration is needed not needed + generated class naming Developers have to learn only usage of library rules Type-Safe No Yes
Which we should adopt?
case by case
My Recommend: Dagger2 pattern
Start ↓ Yes Yes Yes Is not solidity “Butter Like beautiful Don’t forget → → → app necessary? Knife” API? proguard conf? pattern ↓ No ↓ No ↓ No “Dagger2” pattern “Dagger2” pattern “Dagger2” pattern