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

Bootstrapping von iOS-Projekten

Bootstrapping von iOS-Projekten

Slides of the meetup of the Mobile Maultaschen on April 09, 2019.

The demonstrator is available on GitHub.

Gregor Dschung

April 09, 2019
Tweet

Other Decks in Programming

Transcript

  1. © 2019 andrena objects ag Experts in agile software engineering

    Mobile Maultaschen Bootstrapping von iOS-Projekten 09.04.2019 Gregor Dschung [email protected]
  2. © 2019 andrena objects ag Experts in agile software engineering

    2 Über mich Gregor Dschung Agile Software Engineer seit 2013 bei andrena seit 2016 in der iOS-Entwicklung @chkpnt @chkpnt
  3. © 2019 andrena objects ag Experts in agile software engineering

    3 Nächsten Termine Mo., 06.05.2019: ObjektForum „Reaktive Programmierung in verständlichen Worten“ Alex Krause, QAware 06. bis 08.11.2019: XP Days Germany
  4. © 2019 andrena objects ag Experts in agile software engineering

    5 Motivation Today‘s code is the legacy code of tomorrow.
  5. © 2019 andrena objects ag Experts in agile software engineering

    6 Motivation Today‘s code is the legacy code of tomorrow the day after tomorrow.
  6. © 2019 andrena objects ag Experts in agile software engineering

    7 Motivation Today‘s code is the legacy code of tomorrow next week. Maintainability Comprehensibility / Readability … for other people than myself!
  7. © 2019 andrena objects ag Experts in agile software engineering

    13 Goal • A new developer should be able to understand the structure easily • A new developer knows where to add new features
  8. © 2019 andrena objects ag Experts in agile software engineering

    15 Xcode Groups • Helps to keep structure • Should not contain „too many“ files • Should match the file system structure • Less of a problem since Xcode 9 • Keep filesystem in sync with Xcode: Synx (unmaintained!) • Generate Xcode Project: XcodeGen • In order to fulfill a task, you shouldn‘t be forced to open more than a few groups
  9. © 2019 andrena objects ag Experts in agile software engineering

    16 One possible structure, not THE structure.
  10. © 2019 andrena objects ag Where to put the assets?

    Experts in agile software engineering 18 All in Assets.xcassets Issues: • It‘s gonna get messy. • Where is the asset used? Empfehlung: Assets, die nur innerhalb eines Moduls verwendet wird, gehören dorthin
  11. © 2019 andrena objects ag Where to put the assets?

    Experts in agile software engineering 19 All in Assets.xcassets Issues: • It‘s gonna get messy. • Where is the asset used? Recommendation: • Assets, which are only used in one module, belongs there. (high cohesion)
  12. © 2019 andrena objects ag Experts in agile software engineering

    Structure within the asset catalog • Use folders as namespaces 20
  13. © 2019 andrena objects ag Experts in agile software engineering

    Strings • All in Localizable.strings • It‘s gonna get messy. • Missing context Recommendation: • Strings, which are only used within one module, belongs there (high cohesion) • Use constants for the NSLocalizedString, not the keys! • Which l10n workflow is used? 23
  14. © 2019 andrena objects ag Experts in agile software engineering

    l10n workflow • What is translated? • .strings files • XLIFF (XML Localization Interchange File Format) • Where is the source of the translation? • In the base .strings files? • In the code? 24
  15. © 2019 andrena objects ag Experts in agile software engineering

    25 Here there is nothing to say against a single Localization.strings, as the localization is done by developers through pull-requests.
  16. © 2019 andrena objects ag Experts in agile software engineering

    • Strings are declared in the module in which they are needed ! • But: I do not need the translations during development " • *.strings have to be placed within the module, because there is the source of the translation 26
  17. © 2019 andrena objects ag Experts in agile software engineering

    • Strings are declared in the module in which they are needed ! • But: I do not need the translations during development " • *.strings have to be placed within the module, because there is the source of the translation 27
  18. © 2019 andrena objects ag Experts in agile software engineering

    • Strings are declared in the module in which they are needed ! • Source of the translation is placed nearby the declaration ! • The translations can be placed outside the module ! 28
  19. © 2019 andrena objects ag Experts in agile software engineering

    29 • The source of stringdicts for l10n can‘t be specified programmatically.
  20. © 2019 andrena objects ag 31 Experts in agile software

    engineering BUT: In the XLIFF, the path to the strings-file is wrong ! • Export doesn‘t contain translations • Import won‘t work Workaround: • Assign the strings-file to the main target during export / import
  21. © 2019 andrena objects ag Experts in agile software engineering

    String-based APIs • Localized Strings • Assets • StoryBoards, Nibs, Segues • Reuse-Identifier • Issues: • Unsafe refactoring, runtime errors • IDE support (Code-Completion, Navigation) • Recommendation: • Use a code generator, e. g. R.swift (> 6,1k ★ ) 34 Examples
  22. © 2019 andrena objects ag Experts in agile software engineering

    String-based APIs • Localizable Strings und R.swift • Kommentare werden (noch) nicht übernommen (Github #342) • Stringdicts werden unterstützt aber noch nicht NSStringVariableWidthRuleType (Github #392) 40
  23. © 2019 andrena objects ag Experts in agile software engineering

    Components • Xcode Groups != Java Packages • Swift-Tooling != Java-Tooling • Prevent misuse • Information Hiding • Split your code into Frameworks • Side benefits: • Build-Times, Faster Feedback 42
  24. © 2019 andrena objects ag Experts in agile software engineering

    Even the simple case can easily go wrong 43 UI Business / Domain Data Access Wrong or half-hearted implementation! Why? • Missing orientation • Blindly followed Medium-Articels about VIPER
  25. © 2019 andrena objects ag Experts in agile software engineering

    From layers to onions 44 UI Business / Domain Data Access UI Business / Domain Data Access Domain Services UI SOLID? DIP? Lesenswert: https://www.maibornwolff.de/blog/von-schichten-zu-ringen-hexagonale-architekturen-erklaert
  26. © 2019 andrena objects ag Experts in agile software engineering

    Tests • Don‘t cheat yourself • Don‘t use your productive AppDelegate in your tests • Write useful asserts • … • Don‘t write your mocks by hand • This implies you use mocks ;-) • Every programmer has it‘s own style writing mocks à chaos • Generate your mocks with a tool like SwiftyMocky 50
  27. © 2019 andrena objects ag Experts in agile software engineering

    Tests • Don‘t cheat yourself • Don‘t use your productive AppDelegate in your tests • Write useful asserts • … • Don‘t write your mocks by hand • This implies you use mocks ;-) • Every programmer has it‘s own style writing mocks à chaos • Generate your mocks with a tool like SwiftyMocky 53
  28. © 2019 andrena objects ag Experts in agile software engineering

    Other important topics • Code Reviews • Continuous Integration • UI Architecture • Observability • Dependency Injection • … 55