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

RIBs Architecture - why Uber invented their own wheel

RIBs Architecture - why Uber invented their own wheel

Originally posted here: https://speakerdeck.com/dimaosa/ribs-architecture-why-uber-invented-their-own-wheel

RIBs Architecture was presented by UBER in 2017, since than it become an architecture which gain attention all around the globe.

How UBER solved this problems?
Why did they develop their own solution?
Who should consider this architecture?
How to use it?
Where to start?

This talk was made for CocoaHeads Kyiv #14 which took place Oct 6 2018.

Db84cf61fdada06b63f43f310b68b462?s=128

CocoaHeads Ukraine

October 06, 2018
Tweet

More Decks by CocoaHeads Ukraine

Other Decks in Programming

Transcript

  1. RIBs Architecture. Why UBER invented their own wheel?

  2. Let’s recall the situation when you open someones/yours ViewController and

    you have no clue, What the f*ck is going on here? • We know what is going on here • We don’t ask other person to explain us what is going on here • We write code that is possible to support and extend • Easy to add New features • Easy to reuse Views
  3. Inputs Outputs Imagine that every part is a component

  4. Beer opener Bottle of beer Electricity Bottle is opened !

    Unable to open a beer Beer was opened Inputs Outputs
  5. Things to consider before creating new "Part" What are your

    inputs. (Without inputs your part will not work) What are your outputs. (What are you trying to achieve by implementing it) If we attach Part (child) to Part (parent), must satisfy all inputs and outputs
  6. More examples:

  7. Our body is a perfect example of a set of

    reasonably connected parts System Parts
  8. Our body is a perfect example of a set of

    reasonably connected parts
  9. RIBs Router Ineractor Builder

  10. Massive View Controller

  11. Massive View Controller

  12. State Management

  13. State Management

  14. State Management

  15. Search Station RIB

  16. Ticket Search RIB ⚙

  17. RIB parts Interactor Router ViewController Builder Component Manage RIBs Dependency

  18. Communication

  19. Communication : Upwards

  20. Communication Upwards Question from GitHub.com Question: The issue I'm having

    is finding a good way of passing data from children components (D, E, F) to component in another "subtree" (G). Currently, I'm passing this data through every parent component (for example D -> C - > B -> A -> Root) using Listeners and then I'm using Rx stream to pass data from Root to G. This creates a lots of boilerplate and I wonder if there's a better way of doing it. https://github.com/uber/RIBs/issues/232 Answer: You could pass Mutable Rx stream from Root to children (D, E, F), and make changes in D, E, F, after that pass NonMutable Rx Stream to G (if you need only listen). So in that way you don't need to use Listeners in A, B, C
  21. Action Action Action Present here

  22. Communication : Downwards

  23. Streams - LocationManagerStream - ProfileManager - TrainColorPalette - TrainService -

    SearchLocationsStream ⚙ - PreferencesStream - TicketsStream Typically, we store state inside streams of immutable models that re-emit values when the details change.
  24. Streams

  25. Streams • MutableStream and Stream

  26. Streams

  27. Streams

  28. Streams

  29. No architecture View Controller vision Day 1 Day 30

  30. RIBs vision Day 1 Day 30

  31. Why UBER invented their own wheel? • Isolation and Testability.

    Classes must be easy to unit test and reason about in isolation. Individual RIB classes have distinct responsibilities like: routing, business, view logic, creation. Plus, most RIB logic is decoupled from child RIB logic. This makes RIB classes easy to test and reason about independently. • Tooling for developer productivity. RIBs come with IDE tooling around code generation, memory leak detection, static analysis and runtime integrations - all which improve developer productivity for large teams or small. • An architecture that scales. This architecture has proven to scale to hundreds of engineers working on the same codebase and apps with hundreds of RIBs. • Shared architecture across iOS and Android. Build cross-platform apps that have similar architecture, enabling iOS and Android teams to cross-review business logic code. • Open-Closed Principle. Whenever possible, developers should be able to add new features without modifying existing code. This can be seen in a few places when using RIBs. For example, you can attach or build a complex child RIB that requires dependencies from its parent with almost no changes to the parent RIB.
  32. How to add 50 screens feature, spent 8 months, and

    remain linear speed for adding new features… in feature
  33. For whom? •More than 2 people •Feature, feature and one

    more feature •Don’t want to write bad code •Never stop scaling •Invest your time to learn new •Proactive
  34. How to start? Installation for iOS CocoaPods To integrate RIBs

    into your project add the following to your Podfile: pod 'RIBs', '~> 0.9' Carthage To integrate RIBs into your project using Carthage add the following to your Cartfile: github "uber/RIBs" ~> 0.9
  35. Where to go next? RIBs engineer talk about architecture https://www.youtube.com/watch?v=FfwZSk6VRVY

    RIBs Github https://github.com/uber/RIBs RIBs Slack channel, talk with creators one-to-one uber-ribs.slack.com Engineering Scalable, Isolated Mobile Features with Plugins at Uber https://eng.uber.com/plugins/
  36. Wanna talk more? facebook https://www.facebook.com/dima.osadchy email dima.osadchy@gmail.com

  37. The End ? Or just the beginning