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

RIBs Architecture - why Uber invented their own...

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.

CocoaHeads Ukraine

October 06, 2018
Tweet

More Decks by CocoaHeads Ukraine

Other Decks in Programming

Transcript

  1. 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
  2. Beer opener Bottle of beer Electricity Bottle is opened !

    Unable to open a beer Beer was opened Inputs Outputs
  3. 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
  4. Our body is a perfect example of a set of

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

    reasonably connected parts
  6. 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
  7. 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.
  8. 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.
  9. How to add 50 screens feature, spent 8 months, and

    remain linear speed for adding new features… in feature
  10. 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
  11. 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
  12. 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/