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

Nowe Dependency Injection w aplikacji Allegro iOS

Nowe Dependency Injection w aplikacji Allegro iOS

Allegro Tech Live #17 (held in Polish)

W aplikacji Allegro dla kupujących mamy 90+ modułów. W prezentacji opowiem o tym jak je generujemy oraz jakie podejście obraliśmy aby zapewnić współdzielenie zależności pomiędzy tymi modułami. W nowym podejściu nie musimy tworzyć cross-zależności pomiędzy modułami co istotnie skraca czas kompilacji.

FB Event: https://www.facebook.com/events/447710906562080
Recording: https://www.youtube.com/watch?v=Ra5T7MbUXW0&t=4690s

Avatar for Maciej Piotrowski

Maciej Piotrowski

April 15, 2021
Tweet

More Decks by Maciej Piotrowski

Other Decks in Programming

Transcript

  1. Clean Build Time (s) 190 88 177 220 250 307

    (Jun 2019 - April 2021) 238 59
  2. Clean Build Time (s) 190 88 177 220 250 307

    (Jun 2019 - April 2021) 238 59 94 moduły
  3. Clean Build Time (s) 190 88 177 220 250 307

    (Jun 2019 - April 2021) 238 czas kompilacji < 60 s 59 94 moduły
  4. The Build iOS Conf SG 2021: Speeding up the build

    process of a monolithic application
  5. The Build iOS Conf SG 2021: Speeding up the build

    process of a monolithic application
  6. The Build iOS Conf SG 2021: Speeding up the build

    process of a monolithic application
  7. The Build iOS Conf SG 2021: Speeding up the build

    process of a monolithic application
  8. The Build iOS Conf SG 2021: Speeding up the build

    process of a monolithic application
  9. The Build iOS Conf SG 2021: Speeding up the build

    process of a monolithic application
  10. OLD

  11. Cart Interface ItemPage Interface Payments Interface SearchEngine Interface Lists Interface

    … Address Interface Networking Interface Networking Cart ItemPage Payments SearchEngine Lists … Address NEW
  12. Cart Interface ItemPage Interface Payments Interface SearchEngine Interface Lists Interface

    … Address Interface Cart ItemPage Payments SearchEngine Lists … Address NEW
  13. Cart Interface ItemPage Interface Payments Interface SearchEngine Interface Lists Interface

    … Address Interface Cart ItemPage Payments SearchEngine Lists … Address NEW
  14. import NetworkingInterface class ModuleConfiguration: ModuleConfiguring { func registerImplementations(in registry: Registry)

    { registry.register(type: Networking.self, service: NetworkingAdapter()) !//Module: Networking NEW
  15. import NetworkingInterface class ModuleConfiguration: ModuleConfiguring { func registerImplementations(in registry: Registry)

    { registry.register(type: Networking.self, service: NetworkingAdapter()) } } !//Module: Networking NEW
  16. import NetworkingInterface class ModuleConfiguration: ModuleConfiguring { func registerImplementations(in registry: Registry)

    { registry.register(type: Networking.self, service: NetworkingAdapter()) } } !//Module: Networking NEW
  17. import NetworkingInterface class ModuleConfiguration: ModuleConfiguring { func start(with resolver: Resolver)

    { guard let networking = resolver.resolve(type: Networking.self) !//Module: OfferPage NEW
  18. import NetworkingInterface class ModuleConfiguration: ModuleConfiguring { func start(with resolver: Resolver)

    { guard let networking = resolver.resolve(type: Networking.self) } } !//Module: OfferPage NEW
  19. import NetworkingInterface class ModuleConfiguration: ModuleConfiguring { func start(with resolver: Resolver)

    { guard let networking = resolver.resolve(type: Networking.self) } } !//Module: OfferPage NEW
  20. let container: Registry & Resolver = !//… modules.forEach { $0.registerImplementations(in:

    container) } modules.forEach { $0.start(with: container) } !//Module: Application NEW
  21. !//Module: DependencyInjection NEW class DependencyContainer: Registry, Resolver { func register<T>(type:

    T.Type, service: Any) { dependencies[DependencyKey(type)] = service } }
  22. !//Module: DependencyInjection NEW class DependencyContainer: Registry, Resolver { } func

    resolve<T>(type: T.Type) !-> T? { return dependencies[DependencyKey(type)] as? T }
  23. • lżejszy workspace (mniej modułów) • zależności międzymodułowe tylko na

    moduły z interfejsami (protokoły) NEW !//Zalety: Nowe Dependency Injection
  24. • lżejszy workspace (mniej modułów) • zależności międzymodułowe tylko na

    moduły z interfejsami (protokoły) • wstrzykiwanie implementacji interfejsów przez poszczególne moduły NEW !//Zalety: Nowe Dependency Injection
  25. • lżejszy workspace (mniej modułów) • zależności międzymodułowe tylko na

    moduły z interfejsami (protokoły) • wstrzykiwanie implementacji interfejsów przez poszczególne moduły • ekstrakcja potrzebnych typów przez poszczególne moduły NEW !//Zalety: Nowe Dependency Injection
  26. allegro.tech Speeding up iOS builds with Bazel Speeding up warm

    builds in Xcode Maciej Piotrowski twitter.com/macpiotrowski89