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

September 30, 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. –Esteban Torres “An app is the tiny cute boxes you

    have in your phone that show some other bigger boxes when you touch them.” Photo by Andreas Kind on Unsplash
  4. Building Search Background Synchroniser Home Session Settings Database Client User

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

    by Artem Sapegin on Unsplash
  6. Session Building Search Background Synchroniser Home Session Settings Database Client

    Search Database Client APP
  7. 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 " #
  8. None
  9. None
  10. Problem #2 Slow iterations building and testing features Photo by

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

  12. What is a µfeature µfeature Sources Tests App BTT Build,

    test and try
  13. What is a µfeature µfeature Sources Tests App Source Source

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

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

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

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

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

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

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

  21. Product µfeatures Built using foundation µfeatures µfeatures that the user

    can feel/consume
  22. 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
  23. Product µfeatures Product
 µfeature View / View Controller Service Public

    Interface
  24. Using µfeatures Product
 µfeature Application Product
 µfeature Product
 µfeature Product


    µfeature Navigation View Controller View Controller View Controller View Controller
  25. Using µfeatures Product
 µfeature Application Product
 µfeature Product
 µfeature Product


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

    Sources Sources
  27. 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)
  28. 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
  29. Dependency Inversion Application (glue layer) A Sources B Sources C

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

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

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

    Lindsay Malatesta on Unsplash
  33. 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
  34. µ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 Feature Tests Per-project Schemes Features tests Features examples Features Workspace schemes
  35. Demo Photo by LoboStudio Hamburg on Unsplash

  36. Downsides Photo by Samuel Zeller on Unsplash

  37. Maintenance Build settings Schemes / Targets / Dependencies

  38. Maintenance XcodeGen github.com/yonaskolb/xcodegen

  39. Dependencies clarity What depends on what?

  40. 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.
  41. References • Microservices: A definition of this new architectural term.

    • Introduction to Framework Programming Guide. • Embedding frameworks in an app. • Framework Oriented Programming. • Static & Dynamic libraries. • Modular Xcode projects.
  42. Dziękuję (Thank you) Photos from Unsplash
 Slides: https://goo.gl/4XUj3Y Twitter: @pepibumur