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

MTC2018 - Implementing TypeErasure in ViewController

92cdcff298e89e2fcd2fb705155c2d4b?s=47 mercari
PRO
October 04, 2018

MTC2018 - Implementing TypeErasure in ViewController

Speaker: Nobuo Saito

To develop our app, we use MicroViewController, which we introduced at iOSDC, and we have also implemented the idea of MicroFrameworks. A common issue with using MicroFrameworks is circular dependencies, but by using the MicroViewController model, we can implement TypeErasure for ViewController. We call this ViewControllerRequest. Today I will talk about ViewControllerRequest, our prized service that solved the problem of circular dependencies and greatly reduced the work required for refactoring.

92cdcff298e89e2fcd2fb705155c2d4b?s=128

mercari
PRO

October 04, 2018
Tweet

Transcript

  1. Implementing TypeErasure in ViewController Nobuo Saito Tech Lead (iOS)

  2. Making TypeErasure for ViewController

  3. Tech Lead iOS Nobuo Saito

  4. Agenda What’s New in Mercari/Mew Technical Debt/Assets Composition of Mercari

    iOS ViewControllerRequest Conclusion
  5. Agenda What’s New in Mercari/Mew Technical Debt/Assets Composition of Mercari

    iOS ViewControllerRequest Conclusion
  6. iOSDC Review MicroViewController = One of the microservices implemented in

    iOS github.com/mercari/Mew
  7. TableView CollectionView Auto/manual sizing LifeCycle/reuse

  8. Agenda What’s New in Mercari/Mew Technical Debt/Assets Composition of Mercari

    iOS ViewControllerRequest Conclusion
  9. iOS Technical Debt Massive ViewController 1 layer Objective-C Tight binding

    between classes
  10. Technical Debt? linux swiftc UIKit

  11. Increase in maintenance cost Negative influence from knowledge of existing

    code The Nature of Technical Debt
  12. Technical Assets Features work properly Features can be reused New

    features are not added Code cannot be accessed
  13. Agenda What’s New in Mercari/Mew Technical Debt/Assets Composition of Mercari

    iOS ViewControllerRequest Conclusion
  14. All modules import Kit/Entity The app imports all modules    

    MercariKit     MercariEntity     Prod1     Listing     ItemDetail     Search     Mercari     Prod2     Prod3
  15. Pros of Microframeworks project.pbxproj Swift internal Reduces unnecessary sharing

  16. Cons of Microframeworks Circular dependency Dynamic linking time Bundle Not

    supported by some OSS
  17. Cons of Microframeworks Circular dependency Dynamic linking time Bundle Not

    supported by some OSS
  18.     MercariKit     MercariEntity     Prod1     Listing     ItemDetail

        Search     Mercari     Prod2     Prod3 ItemDetail cannot import Search
  19. Overloads functions: (Request) -> Response

  20.     MercariKit     MercariEntity     Prod1     Listing     ItemDetail

        Search     Mercari     Prod2     Prod3 Get all Mercari resources from EnvironmentProvider EnvironmentProvider User GetProfileRequest MercariEnvironment
  21.     MercariKit     MercariEntity     Prod1     Listing     ItemDetail

        Search     Mercari     Prod2     Prod3 Definition of request Type class, Type implementation DIP (Dependency Inversion Principle) protocol struct function
  22. Agenda What’s New in Mercari/Mew Technical Debt/Assets Composition of Mercari

    iOS ViewControllerRequest Conclusion
  23. None
  24.     MercariKit     MercariEntity     Prod1     Listing     ItemDetail

        Search     Mercari     Prod2     Prod3 3 protocols defined in MercariKit Injectable/Interactable
  25.     MercariKit     MercariEntity     Prod1     Listing     ItemDetail

        Search     Mercari     Prod2     Prod3 Make ViewControllers Input/Output in MercariEntity Injectable/Interactable Input Output
  26.     MercariKit     MercariEntity     Prod1     Listing     ItemDetail

        Search     Mercari     Prod2     Prod3 Mercari can import Search Injectable/Interactable Input Output let vc = SearchVC(...)
  27.     MercariKit

  28.     MercariKit

  29.     MercariKit

  30.     MercariEntity

  31.     Mercari

  32.     ItemDetail

  33.     MercariKit     MercariEntity     Prod1     Listing     ItemDetail

        Search     Mercari     Prod2     Prod3 Get ViewController instance from EnvironmentProvider API Gateway for VC ViewControllerRequest Search IO let vc = SearchVC(...)
  34.     MercariKit     MercariEntity     Prod1     Listing     ItemDetail

        Search     Mercari     Prod2     Prod3 Code cannot be referenced Features work properly
  35.     MercariKit     MercariEntity     Prod1     Listing     ItemDetail

        Search     Mercari     Prod2     Prod3 _人人人人人人人人_ >Huge buried treasure!<  ̄Y^Y^Y^Y^Y^Y^Y^ ̄ ViewControllerRequest ViewControllers IO WrapperOfObjC
  36. Agenda What’s New in Mercari/Mew Technical Debt/Assets Composition of Mercari

    iOS ViewControllerRequest Conclusion
  37. Conclusion Divide the framework Split duties and turn liabilities into

    assets To do that, types should be well-defined
  38. None