Improving Developer Experience Through Tools an...

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on. →

Improving Developer Experience Through Tools and Techniques 2022

Krzysztof Zabłocki

June 24, 2022

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

57 slides
  1. Good Developer Experience allows us to • Focus on user/business

    goals • Provide efficient workflows • Keeps us engaged with the work we are doing • Work smart, not hard • Limits human mistakes by @merowing_ 4
  2. How can we improve Developer Experience? • App architecture •

    Removing required manual steps • Workflow and code automa;on • Building developer tools • Shortening feedback loops by @merowing_ 6
  3. How to gauge if you should invest 3me into tooling?

    • Is this inconvenient just for me? • Do other folks in my team run into the same kind of problems? • How o=en does it happen? • What's the total team @me per week wasted on this problem? by @merowing_ 7
  4. How to gauge if you should invest 3me into tooling?

    • NYT project used internal / 3rd party tools with each build • The total on each build adds about 6s, only 6s, right? • I measured that I build between 200-400 Dmes daily, and 90% of the Dmes we don't need those tools to run again • We had ~30 iOS developers touching the main app • Lower threshold = 200 $mes * 6s * 30 devs * 90% => 9 hours wasted per day by @merowing_ 8
  5. How to gauge if you should invest 3me into tooling?

    • This means we were was-ng 45 hours per week. • If we can improve that, it's almost like hiring a new full--me developer, except it's free. • Is it worth inves-ng -me to improve it? • ✔ Definitely • How to do it? Custom pre-process script on pre-commit / CI • Read more @ my blog h4ps:/ /bit.ly/3uwbqhL by @merowing_ 9
  6. Issue - Manual Steps Need to fill out some fields?

    e.g., login creden4als • Use user breakpoints • Data never leaves your machine • Easy to disable by @merowing_ 12
  7. Issue - Manual Steps Are you working on a long-running

    feature? • Build-phase script that allows you to create #if branches per developer (e.g., h;ps:/ /bit.ly/3mmfLRP) #if merowing showARExperience(StubARData(...)) #endif by @merowing_ 14
  8. Issue - Retain Cycles Apple: Xcode Memory Graph Debugger +

    Leaks Instrument • Do you trust people will always run those tools and analyze their results before submi7ng Pull Requests? by @merowing_ 16
  9. Issue - Retain Cycles Open Source: Life'meTracker • How many

    instances of class X should ever be alive? • Works in Swi< and Objec?ve-C • Surface new retain cycle as you create them, not a<er you've finished the feature by @merowing_ 17
  10. Issue - Retain Cycles Open Source: krzysztofzablocki/Life3meTracker Straigh(orward integra/on: 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() } } by @merowing_ 18
  11. Issue - Data dependencies • Design your processing like a

    pipeline • Protocol at each stage, so it's easy to change by @merowing_ 21
  12. Issue - Data dependencies • Wri%ng tests for your ViewModel?

    • Bug report requires specific data? • Replace Model Converter with Fake Models by @merowing_ 22
  13. Issue - Data dependencies • Do you want to see

    how your whole applica3on reacts to specific data changes, but the backend isn't ready? • Easily load external data to the applica3on • In simulator ? loading from a local file would be preferred • On device? we need to load from a network server • We need real-3me updates by @merowing_ 23
  14. Issue - Data dependencies Open Source: KZFileWatchers • Works in

    Swi, and Objec4ve-C • FileWatcher.Local is useful for observing local file changes e.g., observing files on the developer desktop. • FileWatcher.Remote can be used to observe files on the web. Both Etag headers and Last-Modified-Date are supported. by @merowing_ 24
  15. Issue - Data reproduc/on Can't reproduce bugs because your data

    changes o3en? • Every app deals with raw NSData at some point in the pipeline • Pipe it through (Identifier, Data) -> Data • Use only returned data: • If the app is in recording mode, it persist data in cache • If you are in reproduc=on mode, it loads data from the cache • Read more @ my blog h/ps:/ /bit.ly/3mrna2i by @merowing_ 27
  16. Issue - Tes(ng Diffs Comparing objects is terrible. • Open

    Source Difference - Pure func.on Mirror based diffing by @merowing_ 31
  17. Sourcery • Sourcery is like a pre-processor • Sourcery(input: Swift)

    -> Either<Swift, Anything> • Used in over 40 000 apps. • In massive code-bases like Airbnb, Bumble, etc. • Adds annota?on support to SwiA language • Allows fine-grained control over the genera?on • Sourcery can generate any code if you can describe the algorithm by @merowing_ 33
  18. Example: Automa.c Se1ngs struct Calculation: AutomaticSettings { var text =

    "" var mode = Mode.linearRegression } // sourcery: injectFooter struct Smoothing { var dayPeriod = 7 var algorithm = Algorithm.movingAverage struct Grouped { var level: Float = 1 var prettyCool = true } var grouped: Grouped = .init() } by @merowing_ 35
  19. Example: A/B Tests struct ABTests { var meterLimit = Test<MeterLimit>(

    default: .control ) var calendarReminder = Test<CalendarReminder>( default: .control ) .... } by @merowing_ 36
  20. Example: JS <-> Swi1 bridge // 1 case -> 1

    command case nodesSetAutoFade(ids: [String], maxDistance: CGFloat) case nodesSetVisibility(showIds: [String]?, hideIds: [String]?) case materialSetProperties( id: String, material: String, properties: ARViewer.Model.MaterialProperties ) // automatically bridges JS <-> Swift and provided as fully typed enum switch (command) { case let .materialSetProperties(id, materialName, properties): by @merowing_ 37
  21. But ... it's a dependency. I don't know if my

    team will want or can integrate it? by @merowing_ 38
  22. Issue - Tes(ng Mocks • Open Source Swi&yMocky - Sourcery

    based framework for powerful mocking DSL • Open Source Sourcery - AutoMockable template by @merowing_ 43
  23. Issue - Long itera/on cycle First, we can split the

    project into many different modules. • Improves modular architecture design • Forces developers to think about public API and module boundaries • Each framework has its test suite that can run fast • Enables use of playgrounds or small projects • .dylib loading is no longer a significant concern, and we have staBc libs by @merowing_ 47
  24. Issue - Long itera/on cycle Open Source: KZPlayground • Both

    Swi* and Objec3ve-C • Custom DSL for exposing control variables (sliders, image pickers, trigger buEons). • It's easy to add the framework to exis3ng code-base • Works with Injec3onForXcode by @merowing_ 48
  25. Not convinced yet? What if you only needed a maximum

    of two line change to hot- reloading your UIKit / AppKit / tvOS / Swi>UI project? UIKit/AppKit: // from let vc = MainViewController(...) // to let vc = Inject.ViewControllerHost(MainViewController(...)) by @merowing_ 50
  26. Not convinced yet? What if you only needed a maximum

    of two line change to hot- reloading your UIKit / AppKit / tvOS / Swi>UI project? Swi$UI: @ObservedObject private var iO = Inject.observer variable var body: some View { ... .enableInjection() } by @merowing_ 52
  27. Issue - Long itera/on cycle What if you can't split

    up your project easily or it's s4ll too slow? • Open Source: Inject + Injec+onForXcode • Hot Reloading for Swi: and Objec+ve-C • No run+me involved, full Swi: support • Can be integrated as an SPM package by @merowing_ 54
  28. Summary • Crea&ng a good developer experience should be one

    of the main goals of your applica&on architecture design • Time invested into improving your team developer experience can yield huge ROI for your business • By enabling your developers to work on the features that maAer to the business • If a mythical 10x developer exists, it would be the person that makes ten team members more efficient. • Ask yourself if the problems you are facing are isolated or affect other devs? • Consider geHng Sourcery Pro to automate your workflows • Give Inject a try if you want to save hours of development :me per week by @merowing_ 55

More Decks by Krzysztof Zabłocki

Other Decks in Programming