Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Bohemian Wrapsody

Bohemian Wrapsody

In this talk, Dmytro Danylyk will explain why wrapping third-party library is best practice? Why should you actually care? What are the benefits for you and your team?

Original presentation available here: https://docs.google.com/presentation/d/1EAkTS7wCyzf5J4hvf4ARSDt9UGJVydWFVxpYLv2SzP8/edit?usp=sharing

Dmytro Danylyk

April 15, 2019
Tweet

More Decks by Dmytro Danylyk

Other Decks in Technology

Transcript

  1. Benefits - define the API of the wrapper - more

    flexible to changes - ease updates during breaking changes - experiment with new technologies - share common logic - predefined configuration - additional functionality - loosely coupled system - easier to test - reuse modules across apps
  2. Glide.with(context) .load("https://...") .apply(RequestOptions() .placeholder(R.drawable.placeholder) .transform(CircleCrop())) library api ImageLoader(context).load( model =

    ImageModel.URL("https://..."), placeholder = Placeholder.FromResource(R.drawable.placeholder), transformation = Transformation.Circular ) Your api
  3. Benefits - define the API of the wrapper - more

    flexible to changes - ease updates during breaking changes - experiment with new technologies - share common logic - predefined configuration - additional functionality - loosely coupled system - easier to test - reuse modules across apps
  4. main-module image-loader-module glide-library Glide 4.9.0 Breaking changes Glide 4.8.0 Breaking

    changes Glide 4.7.0 Breaking changes Glide 4.6.0 Breaking changes Glide 4.5.0 Breaking changes Glide 4.4.0 Breaking changes Glide 4.3.0 Breaking changes
  5. main-module image-loader-module glide-library Glide 4.9.0 Breaking changes Glide 4.8.0 Breaking

    changes Glide 4.7.0 Breaking changes Glide 4.6.0 Breaking changes Glide 4.5.0 Breaking changes Glide 4.4.0 Breaking changes Glide 4.3.0 Breaking changes Resolve here
  6. Benefits - define the API of the wrapper - more

    flexible to changes - ease updates during breaking changes - experiment with new technologies - share common logic - predefined configuration - additional functionality - loosely coupled system - easier to test - reuse modules across apps
  7. Benefits - define the API of the wrapper - more

    flexible to changes - ease updates during breaking changes - experiment with new technologies - share common logic - predefined configuration - additional functionality - loosely coupled system - easier to test - reuse modules across apps
  8. Benefits - define the API of the wrapper - more

    flexible to changes - ease updates during breaking changes - experiment with new technologies - share common logic - predefined configuration - additional functionality - loosely coupled system - easier to test - reuse modules across apps
  9. Benefits - define the API of the wrapper - more

    flexible to changes - ease updates during breaking changes - experiment with new technologies - share common logic - predefined configuration - additional functionality - loosely coupled system - easier to test - reuse modules across apps
  10. Benefits - define the API of the wrapper - more

    flexible to changes - ease updates during breaking changes - experiment with new technologies - share common logic - predefined configuration - additional functionality - loosely coupled system - easier to test - reuse modules across apps
  11. When? - if you have multiple projects - if you

    work on a long-term project - if you use library as a temporary solution
  12. When? - if you have multiple projects - if you

    work on a long-term project - if you use library as a temporary solution
  13. When? - if you have multiple projects - if you

    work on a long-term project - if you use library as a temporary solution
  14. How? - class - package - module - speeds up

    builds (cache + parallel) - separate dependencies - prevents from accidental usage of internal code/resources
  15. How? - class - package - module - speeds up

    builds (cache + parallel) - separate dependencies - prevents from accidental usage of internal code/resources Prefer this
  16. Tips - don’t leave library references in wrapper API -

    make wrapper API as abstract as possible - wrap API which you use, incrementally - put proxy on UI libraries - document things which cannot be wrapped
  17. Tips - don’t leave library references in wrapper API -

    make wrapper API as abstract as possible - wrap API which you use, incrementally - put proxy on UI libraries - document things which cannot be wrapped
  18. val observable: Observable<Result> = AndroidPermissions() .observe(permission = Permission.LOCATION) val publisher:

    Publisher<Result> = AndroidPermissions() .observe(permission = Permission.LOCATION)
  19. val observable: Observable<Result> = AndroidPermissions() .observe(permission = Permission.LOCATION) val publisher:

    Publisher<Result> = AndroidPermissions() .observe(permission = Permission.LOCATION) io.reactivex
  20. val observable: Observable<Result> = AndroidPermissions() .observe(permission = Permission.LOCATION) val publisher:

    Publisher<Result> = AndroidPermissions() .observe(permission = Permission.LOCATION) io.reactivex org.reactivestreams
  21. Tips - don’t leave library references in wrapper API -

    make wrapper API as abstract as possible - wrap API which you use, incrementally - put proxy on UI libraries - document things which cannot be wrapped
  22. Tips - don’t leave library references in wrapper API -

    make wrapper API as abstract as possible - wrap API which you use, incrementally - put proxy on UI components - document things which cannot be wrapped
  23. val indicatorView = findViewById<IndicatorView>(R.id.indicator) indicatorView.showIndicator(index = 1) val controller =

    IndicatorController(indicatorView) controller.showIndicator(index = 1) Direct usage Proxy
  24. Tips - don’t leave library references in wrapper API -

    make wrapper API as abstract as possible - wrap API which you use, incrementally - put proxy on UI libraries - document things which cannot be wrapped
  25. Library Candidates - logger - analytics - image loader -

    http client - android permissions - schedulers - etc.