SlideShare a Scribd company logo
1 of 23
Download to read offline
Write an Android library
by Romain Rochegude
Introduction
2
Multiple purposes
 
Database
Networking
JSON
UI
etc.
3
Multiple types
 
Helper (ex.: retro t, jackson, ButterKnife)
Structural (ex. : mosby, Android Architecture Components)
Complete feature, customizable with theme (ex.: ZXing, Android
DirectoryChooser)
UI (custom views or animations, ex.: MPAndroidChart)
4
Multiple implementations
 
Pure code (classes and API, ex.: mosby)
 
Annotation processing at compile time (ex.: ButterKnife)
 
Annotation processing at runtime and dynamic proxy (ex.: retro t)
5
1. Design it
6
1.1. Global approach
Modeling with PlantUML
Write immutable objects (because Objects Should Be Immutable)
https://github.com/google/auto/tree/master/value
Failure strategy: fail safe vs. fail fast
Fail safe with resilience (recover, retry)
Fail fast with preconditions
Lazy evaluation (native in Kotlin)
7
1.2. Reactive programming
RxJava and RxAndroid
Observables, subscribers
Asynchronous programming (schedulers)
Functional operators
RxJava - Reactive Extensions for the JVM - a library for
composing asynchronous and event-based programs using
observable sequences for the Java VM.
“
“
RxAndroid - RxJava bindings for Android“ “
8
Bene ts
 
Responsive
 
Resilient
 
Message-driven
9
1.3. Annotations and compile-time processing
 
Java module containing annotation(s)
 
Java module containing processor
 
Android application module to demonstrate it
10
Useful libraries
JavaPoet (and now KotlinPoet)
AutoService
Compile Testing
A Java API for generating .java source les.“ “
A con guration/metadata generator for java.util.ServiceLoader-
style service providers
“
“
Testing tools for javac and annotation processors“ “
11
2. Check it
12
2.1. Testing strategy
 
Fluent assertions (ex.: AssertJ, truth)
 
BDD frameworks (ex.: JGiven, Cucumber)
 
Code coverage and mutation testing (ex.: Zester)
13
2.2. Static analysis
Sonar
Lint
FindBugs
PMD/CPD
Error Prone
Android support annotations
14
3. Ship it
15
3.1. Extra information
 
Documenting using Markdown ( README.md )
 
Generate Javadoc
 
Provide a demo application
16
3.2. Publication/distribution
 
The raw way: svn externals , libs/*.jar , libs/*.aar
 
The modern way: upload les to a repository
Private repository (ex.: Nexus)
Public repository (ex.: JCenter)
Use of Gradle tasks (generate JARs/javadoc, sign, upload)
17
Conclusion
18
 
Follow OOP principles
 
Enjoy the ecosystem (RxJava, APT, libraries, etc.)
 
Provide a robust set of tests...
 
...and a clear API/Javadoc and/or manual and/or demo application
 
Automate whatever is possible with Gradle
19
Addendum: some helpful libraries
https://github.com/android10/arrow (Optional, Preconditions, etc.)
http://www.pojomatic.org/
http://www.vavr.io/ (Lazy, Option, Try, etc.)
https://github.com/jhalterman/failsafe
and so on:
https://github.com/cxxr/better-java
https://github.com/KotlinBy/awesome-kotlin
20
Bibliography (1/2)
http://www.yegor256.com/elegant-objects.html
http://www.yegor256.com/2015/08/25/fail-fast.html
http://liviutudor.com/2012/06/06/simplify-your-singletons/
http://www.vogella.com/tutorials/RxJava/article.html
http://www.slideshare.net/allegrotech/rxjava-introduction-context
21
Bibliography (2/2)
http://hannesdorfmann.com/annotation-
processing/annotationprocessing101
https://jobs.zalando.com/tech/blog/zester-mutation-testing/
https://www.virag.si/2015/01/publishing-gradle-android-library-to-
jcenter/
http://tutos-android-france.com/deployer-librairie-jcenter/
http://slides.com/pivovarit/javaslang-functional-java-done-right#/
22
Logo credits
Social Media graphic by pixel_perfect from Flaticon is licensed under
CC BY 3.0. Check out the new logo that I created on LogoMaker.com
https://logomakr.com/7eyQap7eyQap
23

More Related Content

Similar to Write an Android library

Manuel - SPR - Intro to Java Language_2016
Manuel - SPR - Intro to Java Language_2016Manuel - SPR - Intro to Java Language_2016
Manuel - SPR - Intro to Java Language_2016Manuel Fomitescu
 
Java 7 - New Features - by Mihail Stoynov and Svetlin Nakov
Java 7 - New Features - by Mihail Stoynov and Svetlin NakovJava 7 - New Features - by Mihail Stoynov and Svetlin Nakov
Java 7 - New Features - by Mihail Stoynov and Svetlin NakovSvetlin Nakov
 
Framework engineering JCO 2011
Framework engineering JCO 2011Framework engineering JCO 2011
Framework engineering JCO 2011YoungSu Son
 
JavaScript Miller Columns
JavaScript Miller ColumnsJavaScript Miller Columns
JavaScript Miller ColumnsJonathan Fine
 
Experiences with Evangelizing Java Within the Database
Experiences with Evangelizing Java Within the DatabaseExperiences with Evangelizing Java Within the Database
Experiences with Evangelizing Java Within the DatabaseMarcelo Ochoa
 
IMRCruisetoolbox: A Technical Presentation
IMRCruisetoolbox: A Technical PresentationIMRCruisetoolbox: A Technical Presentation
IMRCruisetoolbox: A Technical PresentationGeertjan Wielenga
 
What is Java Technology (An introduction with comparision of .net coding)
What is Java Technology (An introduction with comparision of .net coding)What is Java Technology (An introduction with comparision of .net coding)
What is Java Technology (An introduction with comparision of .net coding)Shaharyar khan
 
complete_referenceoverview.pdf
complete_referenceoverview.pdfcomplete_referenceoverview.pdf
complete_referenceoverview.pdfzarinrafah
 
Programming in HTML5 With Java Script and CSS3
Programming in HTML5 With Java Script and CSS3Programming in HTML5 With Java Script and CSS3
Programming in HTML5 With Java Script and CSS3Testbells
 
best java training center in chennai
best java training center in chennaibest java training center in chennai
best java training center in chennaisathis est
 
It pro dev_birbilis_20101127_en
It pro dev_birbilis_20101127_enIt pro dev_birbilis_20101127_en
It pro dev_birbilis_20101127_enGeorge Birbilis
 
STAT Requirement Analysis
STAT Requirement AnalysisSTAT Requirement Analysis
STAT Requirement Analysisstat
 
The Java Content Repository
The Java Content RepositoryThe Java Content Repository
The Java Content Repositorynobby
 
Kandroid for nhn_deview_20131013_v5_final
Kandroid for nhn_deview_20131013_v5_finalKandroid for nhn_deview_20131013_v5_final
Kandroid for nhn_deview_20131013_v5_finalNAVER D2
 

Similar to Write an Android library (20)

Manuel - SPR - Intro to Java Language_2016
Manuel - SPR - Intro to Java Language_2016Manuel - SPR - Intro to Java Language_2016
Manuel - SPR - Intro to Java Language_2016
 
Java 7 - New Features - by Mihail Stoynov and Svetlin Nakov
Java 7 - New Features - by Mihail Stoynov and Svetlin NakovJava 7 - New Features - by Mihail Stoynov and Svetlin Nakov
Java 7 - New Features - by Mihail Stoynov and Svetlin Nakov
 
Tech Days 2010
Tech  Days 2010Tech  Days 2010
Tech Days 2010
 
Lo19
Lo19Lo19
Lo19
 
Framework engineering JCO 2011
Framework engineering JCO 2011Framework engineering JCO 2011
Framework engineering JCO 2011
 
Core Android
Core AndroidCore Android
Core Android
 
JavaScript Miller Columns
JavaScript Miller ColumnsJavaScript Miller Columns
JavaScript Miller Columns
 
Experiences with Evangelizing Java Within the Database
Experiences with Evangelizing Java Within the DatabaseExperiences with Evangelizing Java Within the Database
Experiences with Evangelizing Java Within the Database
 
IMRCruisetoolbox: A Technical Presentation
IMRCruisetoolbox: A Technical PresentationIMRCruisetoolbox: A Technical Presentation
IMRCruisetoolbox: A Technical Presentation
 
What is Java Technology (An introduction with comparision of .net coding)
What is Java Technology (An introduction with comparision of .net coding)What is Java Technology (An introduction with comparision of .net coding)
What is Java Technology (An introduction with comparision of .net coding)
 
Developing android apps with java 8
Developing android apps with java 8Developing android apps with java 8
Developing android apps with java 8
 
complete_referenceoverview.pdf
complete_referenceoverview.pdfcomplete_referenceoverview.pdf
complete_referenceoverview.pdf
 
Programming in HTML5 With Java Script and CSS3
Programming in HTML5 With Java Script and CSS3Programming in HTML5 With Java Script and CSS3
Programming in HTML5 With Java Script and CSS3
 
Introduction of java
Introduction  of javaIntroduction  of java
Introduction of java
 
best java training center in chennai
best java training center in chennaibest java training center in chennai
best java training center in chennai
 
It pro dev_birbilis_20101127_en
It pro dev_birbilis_20101127_enIt pro dev_birbilis_20101127_en
It pro dev_birbilis_20101127_en
 
STAT Requirement Analysis
STAT Requirement AnalysisSTAT Requirement Analysis
STAT Requirement Analysis
 
The Java Content Repository
The Java Content RepositoryThe Java Content Repository
The Java Content Repository
 
Kandroid for nhn_deview_20131013_v5_final
Kandroid for nhn_deview_20131013_v5_finalKandroid for nhn_deview_20131013_v5_final
Kandroid for nhn_deview_20131013_v5_final
 
Java 7: Quo vadis?
Java 7: Quo vadis?Java 7: Quo vadis?
Java 7: Quo vadis?
 

More from Romain Rochegude

Reuse features in Android applications
Reuse features in Android applicationsReuse features in Android applications
Reuse features in Android applicationsRomain Rochegude
 
Android application architecture
Android application architectureAndroid application architecture
Android application architectureRomain Rochegude
 
iOS Swift application architecture
iOS Swift application architectureiOS Swift application architecture
iOS Swift application architectureRomain Rochegude
 
Android: a full-stack to consume a REST API
Android: a full-stack to consume a REST APIAndroid: a full-stack to consume a REST API
Android: a full-stack to consume a REST APIRomain Rochegude
 

More from Romain Rochegude (7)

Reuse features in Android applications
Reuse features in Android applicationsReuse features in Android applications
Reuse features in Android applications
 
Android utilities
Android utilitiesAndroid utilities
Android utilities
 
Java objects on steroids
Java objects on steroidsJava objects on steroids
Java objects on steroids
 
Android application architecture
Android application architectureAndroid application architecture
Android application architecture
 
iOS Swift application architecture
iOS Swift application architectureiOS Swift application architecture
iOS Swift application architecture
 
Android: a full-stack to consume a REST API
Android: a full-stack to consume a REST APIAndroid: a full-stack to consume a REST API
Android: a full-stack to consume a REST API
 
Android Data Persistence
Android Data PersistenceAndroid Data Persistence
Android Data Persistence
 

Recently uploaded

EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
software engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxsoftware engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxnada99848
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 

Recently uploaded (20)

EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
software engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxsoftware engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptx
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 

Write an Android library