$30 off During Our Annual Pro Sale. View Details »

Improving Developer Experience

Improving Developer Experience

Tools and Techniques to improve developer experience for iOS apps.

Krzysztof Zabłocki

March 04, 2019
Tweet

More Decks by Krzysztof Zabłocki

Other Decks in Technology

Transcript

  1. Improving Developer
    Experience

    View Slide

  2. Krzysztof Zabłocki
    @merowing_

    View Slide

  3. Improving Developer Experience
    One of the best investments one can make

    View Slide

  4. Bad Developer Experience
    » Wastes time doing things that aren't important
    » Dealing with bad tooling, architecture or boilerplate
    » Creates a disconnect between our work and the end result
    » Makes us inefficient, creates roadblocks in our way
    » Makes it easy for us to make simple mistakes

    View Slide

  5. Good Developer Experience
    » Allows us to work smart, not hard
    » Enables more efficient workflow
    » Easier to keep connected with our work
    » Keeps focus on what matters and not dealing with our
    technical stack shortcomings
    » Limits human mistakes

    View Slide

  6. Issue - Retain Cycles

    View Slide

  7. Issue - Retain Cycles
    Apple: Xcode Memory Graph Debugger + Leaks Instrument
    » Do you trust people to always run those tools and analyze
    their results before submitting Pull Requests?

    View Slide

  8. Issue - Retain Cycles
    Open Source: LifetimeTracker
    » How many instances of class X
    should ever be alive?
    » Works in Swift and Objective-C
    » Surface new retain cycle as you
    create them, not after you've
    finished the feature

    View Slide

  9. Issue - Retain Cycles
    Open Source: krzysztofzablocki/LifetimeTracker
    Straighforward integration:
    class SectionFrontViewController: UIViewController, LifetimeTrackable {
    static var lifetimeConfiguration = LifetimeConfiguration(maxCount: 1, groupName: "SF VC")
    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
    super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
    /// ...
    trackLifetime()
    }
    }

    View Slide

  10. Issue - Long iteration cycle

    View Slide

  11. Issue - Long iteration cycle

    View Slide

  12. Issue - Long iteration cycle
    Apple: Split up your project into many frameworks
    » + Improves modular architecture design
    » Each framework has its own test suite that can run fast
    » Enables use of playgrounds or small projects
    » - Longer launch times due to dylib loading
    » Leverage cocoapods-aminomo plugin or static libs
    » - Might be complicated to do in existing projects

    View Slide

  13. Issue - Long iteration cycle
    What if you can't split up your project easily?
    » Free tool: InjectionForXcode
    » Code Injection for Objective-C and Swift
    » Its external app you install, no need to unsign your Xcode

    View Slide

  14. Issue - Long iteration cycle
    Open Source: KZPlayground
    » Both Swift and Objective-C
    » Custom DSL for exposing control variables (sliders, image
    pickers, trigger buttons).
    » Easy to add Framework to existing code-base
    » Works great with InjectionForXcode

    View Slide

  15. View Slide

  16. Issue - Boilerplate

    View Slide

  17. Issue - Boilerplate
    Apple: Derived implementations of Equality / Hashing / Codable
    » - Lack of control over the generated implementation
    » Not supportive of non-default cases
    » - Not a generic solution for Boilerplate maintenace, solves
    only a small subset of common algorithms

    View Slide

  18. Issue - Boilerplate
    Open Source: Sourcery
    » Swift code generator, works like a pre-processor
    » Used in over 30 000 apps
    » Adds annotation support to Swift language
    » Allows fine-grained control over the generation
    » Sourcery can generate any boilerplate code if you can describe
    the algorithm once

    View Slide

  19. Issue - Boilerplate
    Open Source: Sourcery
    » Supports 3 different templating languages: Swift, Stencil, and
    EJS
    » Bundled with: Equality, Hashing, Codable, Lenses, Mocks,
    Decorators, LinuxMain, Diffing
    » Powers up projects like ObjectBox and SwiftMocky
    » Enables real-time programming of templates
    » Can be used to generate so much more...

    View Slide

  20. View Slide

  21. Issue - Boilerplate
    Working with assets?
    » Open Source SwiftGen
    » Avoid typos and leverage autocompletion
    » Ensure all assets are available at compile-time, colors, fonts,
    storyboards, and localized strings

    View Slide

  22. Issue - Testing
    Comparing objects is absolutely terrible

    View Slide

  23. Issue - Testing
    Comparing objects is absolutely terrible
    » Open Source Sourcery - property level diffing template
    » Open Source Difference - Pure function Mirror based diffing
    »

    View Slide

  24. Issue - Testing
    Simplifying mocking and stubbing in tests
    » Open Source SwiftyMocky - Sourcery based framework for
    powerful mocking DSL
    » Open Source Sourcery - AutoMockable template

    View Slide

  25. Issue - Data
    dependencies

    View Slide

  26. Issue - Data dependencies
    » Design your processing like a pipeline
    » Protocol at each stage so it's easy to change

    View Slide

  27. Issue - Data dependencies
    » Writing tests for your ViewModel?
    » Bug report requires specific data?
    » Replace Model Converter with Fake Models

    View Slide

  28. Issue - Data dependencies
    » Want to see how your whole application reacts to specific data
    changes but the backend isn't ready?
    » Easily load external data to the application
    » Sim ? loading from mac file would be preferred
    » Device? we need to load from a network server
    » We need real-time updates

    View Slide

  29. Issue - Data dependencies
    Open Source: KZFileWatchers
    » Works in Swift and Objective-C
    » FileWatcher.Local useful for observing local file changes e.g.
    observe file on the developer desktop.
    » FileWatcher.Remote can be used to observe files on the web,
    both Etag headers and Last-Modified-Date are supported.

    View Slide

  30. Issue - Data dependencies
    -> Replace DataProvider with FileWatcher

    View Slide

  31. View Slide

  32. Issue - Data reproduction
    Having a hard time reproducing bugs?
    » Always save your data at Data Provider level to file
    » if the user decides to send a bug report, send those files to
    the cloud
    » You can use file watcher provider to load it on another device
    and re-execute almost all code paths you have
    » Need more power? leverage unidirectional architecture/view
    state to implement time travel

    View Slide

  33. View Slide

  34. Issue - Manual Steps

    View Slide

  35. Issue - Manual Steps
    Need to fill out some fields? e.g. login credentials
    » Use user breakpoints
    » Data never leaves your machine, no git diffs
    » Easy to disable

    View Slide

  36. Issue - Manual Steps
    Working on a long-running feature?

    View Slide

  37. Issue - Manual Steps
    Working on a long-running feature?
    » Build phase script that allows you to create #if branches per
    developer (e.g. http://goo.gl/cLc4ay)
    #if merowing
    showARExperience(StubARData(...))
    #endif

    View Slide

  38. Summary

    View Slide

  39. Summary
    » Good Developer Experience should be one of the core goals of
    architecture design
    » Investing time into improving your team developer experience
    can yield huge efficiency wins for your business and save the
    sanity of your developers
    » If a mythical 10x developer exists it would be the person that
    makes 10 team members more efficient

    View Slide

  40. We're hiring!

    View Slide

  41. Contact
    Twitter merowing_
    Github krzysztofzablocki

    View Slide