Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

[113] lessons from realm

10,525 views

Published on

DEVIEW2015 DAY1. lessons from realm - Emanuele Zattin

Published in: Technology
  • Sex in your area is here: ❶❶❶ http://bit.ly/2F90ZZC ❶❶❶
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Dating for everyone is here: ❶❶❶ http://bit.ly/2F90ZZC ❶❶❶
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m77EgH } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... Download Full doc Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... Download PDF EBOOK here { http://bit.ly/2m77EgH } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

[113] lessons from realm

  1. 1. DEVELOPING ANDROID LIBRARIES: LESSONS FROM REALM EMANUELE ZATTIN (@EMANUELEZ) DEVIEW, SEPTEMBER 14, 2015
  2. 2. THANK YOU NAVER!
  3. 3. LET me KNOW YOU
  4. 4. WHAT IS REALM?
  5. 5. REALM IS A MOBILE DATABASE
  6. 6. REALM IS A ZERO-COPY OBJECT STORE
  7. 7. REALM FOR ANDROID WAS FIRST RELEASED ONE YEAR AGO HERE AT DEVIEW
  8. 8. SOME OF OUR USERS* IN KOREA * Find out more at http://realm.io/kr/users
  9. 9. WHY WOULD YOU WRITE A LIBRARY?
  10. 10. MODULARITY The ability to split your code base into several units with well defined interface. This allows to focus on smaller problems, producing more testable code
  11. 11. REUSABILITY A consequence of modularity. Now you can use that unit again in several places in your projects or accross several different ones
  12. 12. SHAREABILITY A consequence or reusability. You found a nice way to solve a particular issue. Why now helping other developers? Get your name out there!
  13. 13. WHY WOULD YOU WRITE AN ANDROID LIBRARY?
  14. 14. ▸ UI ▸ Looper/Handler ▸ Sensors ▸ Native code ▸ Many more!
  15. 15. WHY WOULD REALM WRITE AN ANDROID LIBRARY?
  16. 16. ▸ UI ▸ Looper/Handler ▸ Sensors ▸ Native code ▸ Many more!
  17. 17. CHALLENGE 1HOW TO START AN ANDROID LIBRARY PROJECT?
  18. 18. THE PROBLEM ANDROID STUDIO ALLOWS YOU TO: ▸ Create a new Application project ▸ Create a new Library project ▸ Add a new Application module ▸ Add a new Library module
  19. 19. SOLUTION 1 From Android Studio: 1. Create a new Application project 2. Add a new Library module 3. Remove the Application module
  20. 20. SOLUTION 2 From the command line: android create lib-project -t 1 -k kr.deview.awesomelib -p . -g -v 1.3.0 -t: target (Use android list targets to get a list of target ids) -k: package name -p: path to the project -g: make it a Gradle project (requires SDK >= 19) -v: version of the Android Gradle plugin to use
  21. 21. CHALLENGE 2API DESIGN
  22. 22. SOLUTION DEFINE WHAT A GOOD API IS
  23. 23. ▸ Easy to learn ▸ Easy to use, even without documentation ▸ Hard to misuse ▸ Easy to read and maintain code that uses it ▸ Sufficiently powerful to satisfy requirements ▸ Easy to extend ▸ Appropriate to audience
  24. 24. STAND ON THE SHOUDERS OF GIANTS ▸ Effective Java 2 by Joshua Bloch ▸ How To Design A Good API and Why it Matters by Joshua Bloch
  25. 25. CHALLENGE 3TESTING
  26. 26. TESTING IS EVEN MORE IMPORTANT FOR LIBRARIES THAN FOR APPLICATIONS BECAUSE YOU HAVE NO IDEA HOW YOUR CUSTOMERS ARE GOING TO USE IT.
  27. 27. SOLUTION 1 PREFER JUNIT41 OVER JUNIT3 1 Because parametric tests will save your life!
  28. 28. SOLUTION 2 AUTOMATE ALL THE THINGS!
  29. 29. LET JENKINS BECOME YOUR BEST FRIEND
  30. 30. USEFUL JENKINS PLUGINS ▸ Job Config History ▸ Git ▸ Android Emulator ▸ Matrix Job2 ▸ Junit2 2 It comes preloaded with Jenkins
  31. 31. SOLUTION 3 WRITE SAMPLE APPS!
  32. 32. ▸ Additional integration tests ▸ Showcase how to use your library ▸ Validate your core principles
  33. 33. CHALLENGE 4JAR OR AAR?
  34. 34. DO YOU WANT TO SUPPORT ECLIPSE? SHOW ME YOUR HANDS ONCE AGAIN
  35. 35. SOLUTION USE AAR
  36. 36. CHALLENGE 5WHERE TO PUBLISH?
  37. 37. SOLUTION BINTRAY
  38. 38. HOW TO PRODUCE A SOURCE JAR task androidSourcesJar(type: Jar) { from android.sourceSets.main.java.srcDirs }
  39. 39. HOW TO PRODUCE A JAVADOC JAR android.libraryVariants.all { variant -> task("javadoc${variant.name.capitalize()}", type: Javadoc) { description "Generates Javadoc for $variant.name." group 'Docs' source = variant.javaCompile.source ext.androidJar = files(project.android.getBootClasspath()) classpath = files(variant.javaCompile.classpath.files) + ext.androidJar exclude '**/BuildConfig.java' exclude '**/R.java' } }
  40. 40. Bintray also provides a Gradle plugin for the actual publishing The configuration is not trivial, and in the beginning it might be easier to just do the release manually on the binary website
  41. 41. CHALLENGE 6INTROSPECTION IS SLOW
  42. 42. Sometimes libraries need to be smart behind the scenes to save the user from writing boilerplate code
  43. 43. SOLUTION ANNOTATION PROCESSING
  44. 44. ! PROS: ▸ It allows you to write new Java files ▸ It happens at compilation time ! CONS ▸ It does not allow to modify existing code ▸ It's not very easy to use
  45. 45. SOME VERY cool libraries USE IT! ▸ Dagger ▸ Butter Knife ▸ AutoValue/AutoParcel ▸ Realm
  46. 46. BAD NEWS Android does not include the package javax.annotation.processing
  47. 47. WORKAROUND Create two Java sub-projects: 1. annotations (used both by the library and the processor) 2. annotations processor
  48. 48. YOU NEED TO INCLUDE THE ANNOTATIONS IN THE JAVADOC android.libraryVariants.all { variant -> task("javadoc${variant.name.capitalize()}", type: Javadoc) { description "Generates Javadoc for $variant.name." group 'Docs' source = variant.javaCompile.source source "../annotations/src/main/java" // <-- Remember this! ext.androidJar = files(project.android.getBootClasspath()) classpath = files(variant.javaCompile.classpath.files) + ext.androidJar exclude '**/BuildConfig.java' exclude '**/R.java' } }
  49. 49. CHALLENGE 7 SOMETIMES ANNOTATION PROCESSING IS NOT POWERFUL ENOUGH
  50. 50. ! PROS: ▸ It allows you to write new Java files ▸ It happens at compilation time ! CONS ▸ It does not allow to modify existing code ▸ It's not very easy to use
  51. 51. SOLUTION BYTECODE WEAVING
  52. 52. ! PROS: ▸ It allows to modify existing code ❤ ▸ It's easier to use compared to Annotation Processing ! CONS ▸ You really need to know what you are doing ▸ It might look weird in the debugger
  53. 53. TOOLS THAT ALLOW TO DO BYTECODE WEAVING ▸ Javassist ▸ ASM ▸ AspectJ
  54. 54. THANK YOU STEPHANE NICOLAS! https://github.com/stephanenicolas/injects
  55. 55. CHALLENGE 8NATIVE CODE
  56. 56. THE BAD NEWS THE ANDROID GRADLE PLUGIN DOES NOT SUPPORT NDK ANYMORE
  57. 57. THE GOOD NEWS GOOGLE IS DEVELOPING AN EXPERIMENTAL NEW PLUGIN THAT SUPPORTS NDK
  58. 58. HOW TO START USING IT buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle-experimental:0.2.0' } } apply plugin: 'com.android.model.application'
  59. 59. THE DSL IS SLIGHTLY DIFFERENT model { // <-- This! android { compileSdkVersion = 22 // Now it's a property, not a method buildToolsVersion = "22.0.1" // Same here and the rest of the example defaultConfig.with { // Use the with method applicationId = "com.example.user.myapplication" minSdkVersion.apiLevel = 15 // Use the apiLevel property targetSdkVersion.apiLevel = 22 // Same here versionCode = 1 versionName = "1.0" } } }
  60. 60. FIND OUT MORE ABOUT IT http://tools.android.com/tech-docs/new-build-system/gradle- experimental
  61. 61. ONE ANNOYING LIMITATION NO SUPPORT FOR CREATING AND DEPENDING ON STATIC LIBRARIES
  62. 62. THANK YOU!
  63. 63. REALM 부스에 많이 방문해주세요! 오늘만 열어요

×