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

Building µfeatures

Building µfeatures

Part of the success of most mobile apps these days is having the ability to iterate and deliver features fast. This becomes a challenge when the project and the team grows, and dependencies and friction between teams become more apparent.

In this talk, I’ll introduce the concept of Microfeatures architecture for mobile apps. I’ll go through the core ideas behind it, show practical examples, and explain how development workflow has improved at SoundCloud since we started applying these principles.

B0a336761194918a853deeff1f22b537?s=128

Pedro Piñera Buendía

November 27, 2017
Tweet

Transcript

  1. Building µfeatures Pedro Piñera / @pepibumur

  2. twitter.com/pepibumur - github.com/pepibumur Core iOS Engineer at SoundCloud ppinera.es Personal

    blog github.com/xcodeswift Open source GIF Meister
  3. Building ! Search Background Synchroniser Home Session Settings Database Client

    User actions System events
  4. Problem #1 Strongly coupled features, and no clear APIs Photo

    by Artem Sapegin on Unsplash
  5. Session Building ! Search Background Synchroniser Home Session Settings Database

    Client Search Database Client APP
  6. Building ! Search Background Synchroniser Home Session Settings Database Client

    Search Tests BS
 Tests Home
 Tests Session Tests Settings Tests Database Tests Client Tests APP TESTS Client Tests " #
  7. None
  8. None
  9. Problem #2 Slow iterations building and testing features Photo by

    Lindsay Malatesta on Unsplash
  10. µfeatures Photo by Alex Galperin on Unsplash

  11. What is a µfeature µfeature Sources Tests App ! BTT

    Build, test and try
  12. What is a µfeature µfeature Sources Tests App Source Source

    code (.swift / .h / .m) Resources (.ttf, .storyboard, .xib)
  13. What is a µfeature µfeature Sources Tests App Tests Unit

    tests Integration tests
  14. What is a µfeature µfeature Sources Tests App App Example

    app to try out the feature/s
  15. Problem #1 Strongly coupled features, and no clear APIs Photo

    by Artem Sapegin on Unsplash
  16. Types of µfeatures Foundation Product !

  17. Foundation µfeatures Other µfeatures “know” about them Provide tools and

    extensions to develop other µfeatures
  18. Foundation µfeatures SCCore Client Reachability Keychain Logger Foundation Ext. SCTesting

    Custom assertions XCTest Ext. SCUI Fonts Colors Custom Views UIKit Ext.
  19. Foundation µfeatures $ Foundation
 µfeature Classes Extensions Public Interface

  20. Product µfeatures ! Built using foundation µfeatures µfeatures that the

    user can feel/consume
  21. Product µfeatures ! SCSearch ! SCPlayback ! SCPayments ! SCOffline

    View where user can search for SoundCloud content Payment handling and subscription button/views Player queue handling and views Service to synchronise tracks
 offline
  22. Product µfeatures $ Product
 µfeature View / View Controller Service

    Public Interface
  23. Using µfeatures $ Product
 µfeature Application $ Product
 µfeature $

    Product
 µfeature $ Product
 µfeature Navigation View Controller View Controller View Controller View Controller
  24. Using µfeatures $ Product
 µfeature Application $ Product
 µfeature $

    Product
 µfeature $ Product
 µfeature Services Service Service Service Service Lifecycle Events External Events
  25. Dependencies Application (glue layer) Product µfeatures Foundation µfeatures Sources Sources

    Sources Sources
  26. Dependency with Foundation Application (glue layer) Product Foundation Sources State-free

    component Creates an instance and uses it (e.g Font, Color, View) Stateful component A shared instance is retained from the app
 and shared with the features (e.g Client, Store, Analytics)
  27. Dependency between features Application (glue layer) A Sources Link between

    them Problem 1 It might eventually lead to circular dependencies that can’t be resolved B Sources Problem 2 We need to also compile dependencies, and their dependencies
  28. Dependency Inversion Application (glue layer) A Sources B Sources C

    Sources D Sources Dependency Inversion <B> <C> <D> <A> Foundation µfeatures
  29. Compiling A Application (glue layer) A Sources B C D

    Dependency Inversion <B> <C> <D> <A> Foundation µfeatures <B>
  30. Compiling the app Application (glue layer) A Sources B Sources

    C Sources D Sources Dependency Inversion <B> <C> <D> <A> Foundation µfeatures B
  31. Problem #2 Slow iterations building and testing features Photo by

    Lindsay Malatesta on Unsplash
  32. Example: Home µfeature Home µfeature Core µfeature UI App class

    Client class Analytics class Logger client analytics logger View Controller Service Track Cell Colors Fonts
  33. µfeatures & Xcode Workspace App App Unit Tests UI Tests

    µfeature Sources Unit Tests Example app µfeature Sources Unit Tests Example app Pods Dependency 1 Dependency 2 Pods App Tests Feature Tests Example Feature Tests Example Per-project Schemes Features tests Features examples Features Workspace schemes
  34. Demo Photo by LoboStudio Hamburg on Unsplash

  35. Downsides Photo by Samuel Zeller on Unsplash

  36. Maintenance Build settings Schemes / Targets / Dependencies

  37. Dependencies clarity What depends on what?

  38. Xcode Project Manager github.com/xcode-project-manager App Payments Core UI Generate Xcode

    Project UI Sources/**/* Tests/**/* Name Sources Tests Dependencies Core, Testing More configuration
  39. Takeaways • Scale your project architecture with your team growth

    • Split things before they grow a lot. • Developers shouldn’t spend time fighting the tools. • Keep an eye on how your project/team evolves.
  40. References % • Microservices: A definition of this new architectural

    term. • Introduction to Framework Programming Guide. • Embedding frameworks in an app. • Static & Dynamic libraries. • Modular Xcode projects.
  41. Danke
 schön Photos from Unsplash
 Slides: https://goo.gl/RdjwF8 Twitter: @pepibumur