Save 37% off PRO during our Black Friday Sale! »

Building better android applications

Building better android applications

Activity #07 Androidinight, December 2015 , Mexico City


Erik Jhordan Rey

December 16, 2015


  1. Android Building Better Applications Activity #07 Androidinight, December 2015

  2. - Conventions in android - Tools & Tips currently used

    by Android Developers - What’s S.O.L.I.D? - Clean Architecture - Answers & Questions Talk Schedule #BuildingBetterApps
  3. Erik Jhordan González Reyes Android Developer +Erik Jhordan Rey Caffrey

    @ErikJhordan_Rey erikcaffrey
  4. “Any fool can write code that a computer can understand.

    Good programmers write code that humans can understand. by Martin Fowler”
  5. Conventions in Android #AndroidDevelopers

  6. Convention in Android is not a set of rules for

    define structure project or choosing the character sequence to be used for identifiers which denote resources, source code. These are some recommendations but not strict rules, you can create your own convention (in some cases). Conventions -Project structure -Package structure -File naming -Code naming Android Conventions
  7. New projects normally follow the android gradle project structure that

    is defined on the Android Gradle plugin user guide, we can create a different structure depending on the architecture that we are using in our application. Project Structure
  8. Generates packages containing specific classes with a specific function or

    specific environment. Package Structure
  9. File Naming Type Recommendation Example Class file Class names are

    written in UpperCamelCase. NameBaseType Layout file Layout files should match the name of the Class file. The name of the class should end with the name of the layout file. type_name_suffix fragment_sing_up.xml Resources file Resources file names are written in lowercase_underscore. group_type_name_state_suffix btn_icon_send_disabled.png Common files Some files are auto generated but we may create your own files . color.xml , strings.xml, dimens.xml, styles.xml, themes.xml, plurals.xml, integers.xml, config.xml, menu_sing_up.xml
  10. Code Naming Type Recommendation Example id’s add an id for

    RecyclerView in type_name rv_home values The name values can be varied only about having a convention for them. Dimens Example property_default_group_type_na me app_bar_height_home spacing_small font_size_small variables I recommend it as well as your id using owercase_underscore or camelCase RecyclerView rv_home; RecyclerView rvHome; Language Rules They try to follow the conventions that the language provides you static final String VARIABLE_EXAMPLE = "CONSTANT";
  11. Tools & tips currently used by Android Developers #AndroidDevelopers

  12. Android UI - Tangible surfaces - Print-like design - Meaningful

    motion - Adaptive design
  13. None
  14. Reactive Extensions · RX ReactiveX is a library for composing

    asynchronous and event-based programs by using observable sequences. public class ReactiveFragment extends Fragment { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Observable.just("one", "two", "three", "four", "five") .subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(/* an Observer */); } }
  15. dependencies { compile 'io.reactivex:rxandroid:1.0.1' compile 'io.reactivex:rxjava:1.0.16' } Rx Android

  16. Android + RX

  17. Dagger 2 buildscript { repositories { mavenCentral() } dependencies {

    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' } }
  18. dependencies { compile '' provided '' provided 'org.glassfish:javax.annotation:10.0-b28' } apply

    plugin: ''
  19. AppModule InteractorsModule AppComponent MainModule MainComponent Provides CategoryInteractor getFindItemsInteractor(); MainPresenter getMainPresenter();


  21. Android + Dagger 2

  22. Retrolambda (λ) RetroLambda allows you to write less boilerplate code,

    also clarifies our code making it more readable.
  23. Retroλ + Android buildscript { repositories { mavenCentral() } dependencies

    { classpath 'me.tatarka:gradle-retrolambda:3.2.4' } }
  24. // Required because retrolambda is on maven central repositories {

    mavenCentral() } apply plugin: 'me.tatarka.retrolambda'
  25. // defined in the SDK interface OnClickListener { public void

    onClick(View v); } // your code mButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // do something here } }); Without RetroLambda
  26. With RetroLambda mButton.setOnClickListener((View v) -> { // do something here

  27. Without RetroLambda + RX Observable.just("Hello, world!") .subscribe(new Action1<String>() { @Override

    public void call(String s) { System.out.println(s); } });
  28. With RetroLambda + RX Observable.just("Hello, world!") .subscribe( s -> System.out.println(s));

  29. Android + retroλ

  30. Kotlin Kotlin is a JVM based language created by JetBrains,

    the team behind IntelliJ, which is the base for Android Studio. It´s an object oriented language that includes many ideas from functional programming.
  31. buildscript { repositories { jcenter() } dependencies { classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"

    } } Kotlin en Android
  32. buildscript { ext.kotlin_version = '1.0.0-beta-2423' repositories { jcenter() } dependencies

    { classpath '' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } Kotlin en Android apply plugin: 'kotlin-android' dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" }
  33. Android + Kotlin

  34. what’s S·O·L·I·D? #AndroidDevelopers

  35. #AndroidDevelopers

  36. Single responsibility principle Open / Closed principle Liskov substitution principle

    Interface segregation principle Dependency inversion principle S.O.L.I.D
  37. Single responsibility principle S.O.L.I.D A class must have a unique

  38. Open / Closed principle S.O.L.I.D Every module should be open

    for extension but closed for modification.
  39. Liskov substitution principle S.O.L.I.D Child classes should never break the

    parent class' type definitions.
  40. Interface segregation principle S.O.L.I.D States that clients should not be

    forced to implement interfaces they don't use.
  41. Dependency inversion principle S.O.L.I.D Depend upon abstractions. Do not depend

    upon concrete classes
  42. Clean Architecture #AndroidDevelopers

  43. Entities Use Cases Controllers Gateways Presenters Devices W eb UI

    DB External Interfaces
  44. Presentation Layer Domain Layer Data Layer Model View Presenter Regular

    Java Objects Repository Pattern Interactors Boundaries Clean Architecture
  45. View Presenter Repository Entity Entity Entity Interactor Interactor Interactor ViewEntity

    Presentation Layer Domain Layer Data Layer Clean Architecture
  46. Clean Architecture Benefits • Presentation is decoupled from domain •

    Domain module can be a layer module. • DataLayer decouples the rest of the app • Independent of Frameworks. • Independent of UI • Independent of Database
  47. Answers & Questions #AndroidDevelopers

  48. Thank you! #AndroidDevelopers +Erik Jhordan Rey Caffrey @ErikJhordan_Rey erikcaffrey

  49. Further Reading #AndroidDevelopers • • • • utm_campaign=profiletracking&utm_medium=sssite&utm_source=ssslidevie w •