Laziness-Driven Development in iOS - Mobile Makers Chicago, April 2016

Laziness-Driven Development in iOS - Mobile Makers Chicago, April 2016

Spring 2016 edition of my talk on how Laziness is secretly the best way to code.

Links galore at the end!

C4861b1dfdf3bbb21faec4a1acdf183d?s=128

Ellen Shapiro

April 14, 2016
Tweet

Transcript

  1. Laziness-Driven Development in iOS Mobile Makers Chicago | April 2016

    | by Ellen Shapiro spothero.com | justhum.com | designatednerd.com | @designatednerd
  2. What is Laziness- Driven Development?

  3. The laziness long game.

  4. What is lazy, but is NOT Laziness-Driven Development?

  5. Copy Pasta

  6. Code without tests

  7. Code which is fast to write, but impossible to read

  8. Using libraries for every possible task

  9. What is Laziness-Driven Development? » Smart reuse of code »

    Clear, Readable code » Removal of Stringly-typed code » Making smart decisions today to save yourself time and heartache tomorrow
  10. The primary philosophy of Laziness-Driven Development:

  11. Eventually, You're going to screw something up

  12. only screw it up once. Then, you only have to

    fix it once.
  13. Introductory Laziness-Driven development: Inheritance & MV*

  14. Keep code separated by its purpose

  15. Keep code with the same purpose centralized

  16. Aren't those just Best Practices?

  17. YES

  18. YEs, but they are only the beginning

  19. Beginning Laziness-Driven development: Constants, Structs and Enums

  20. Stringly-typed code Sucks

  21. None
  22. espeshuly if u cant spel... (this is from just one

    repo)
  23. It's the worst

  24. String Constants: The Cure For Speling Problums

  25. Before:

  26. After:

  27. Lazy Swift Ninja:

  28. constants: Not just for strings self.viewWidth = 74; vs. self.viewWidth

    = kProfileViewWidth;
  29. Enums: Even lazier constants

  30. None
  31. None
  32. None
  33. None
  34. None
  35. None
  36. Beginning Laziness-Driven development: Comment And Name Clearly

  37. readability

  38. "programs must be written for people to read, and only

    incidentally for machines to execute."
  39. Variable naming BAD: UIView *v var v = UIView() CGPoint

    pt var pt = CGPoint(1, 1) BETTER: UIView *profileView var profileView = UIView() CGPoint profileOrigin var profileOrigin = CGPoint(1, 1)
  40. Method Naming Objective-C: extremelyLongAndDescriptiveMethodOnLabel:label withParameter:parameter andCompletionBlock:completion Swift: shortButClearMethodOnLabel(label, param, completion)

  41. None
  42. Benefits of clear naming

  43. None
  44. None
  45. None
  46. Some people say: "Comments Lie, Code Doesn't"

  47. If you update code without updating comments, you're doing it

    wrong
  48. //TODO: Write better comments

  49. What < Why

  50. Leave The Campsite Code cleaner than you found it

  51. the goal of good comments and clear naming is the

    same: Future laziness for you
  52. Beginning Laziness-Driven development: Unit Testing

  53. Testing stuff manually is a pain. (Repeat ad nauseam until

    it's fixed)
  54. Remember: Your computer is an awesome robot you can use

    to do your evil bidding
  55. None
  56. None
  57. None
  58. Intermediate Laziness-Driven development: Categories & Extensions

  59. Adding functionality to existing objects (and also to structs in

    Swift)
  60. Objective-C: Categories UIView+XYZApp: - (void)xyz_circleify { self.layer.cornerRadius = CGRectGetWidth(self.frame) /

    2; self.clipsToBounds = YES; }
  61. Watch for method name collsions

  62. Swift: Extensions MyViewExtension: extension UIView { public func xyz_circleify() {

    layer.cornerRadius = CGRectGetWidth(frame) / 2 clipsToBounds = true } }
  63. Watch for method name collsions even in Swift

  64. Intermediate Laziness-Driven development: Laziness-Enhancing Tools

  65. Alcatraz: Xcode plugins for all!

  66. Plugins Before Alcatraz » Download project » Build, run, install,

    » Restart Xcode, » Do the hokey pokey and turn yourself about. » Uninstall by hunting down obscure folder and then forgetting what the hell you were doing in there.
  67. Plugins AFTER Alcatraz » Push button, install plugin. » Push

    other button to see plugin page. » Search plugins easily. » Push button, uninstall plugin. !
  68. Laziness-Enhancing Plugins

  69. VVDocumenter

  70. xTODO

  71. BBFullIssue Navigator

  72. SCXcodeMiniMap

  73. None
  74. A place for ideas

  75. Get a better idea of what is simple and what

    is not
  76. MOGenerator - Make Core Data less painful

  77. MOGenerator Kills Stringly-Typed Code just to watch it die

  78. Lazier Code with MOGenerator

  79. Advanced Laziness-Driven development: UI Testing

  80. KIF

  81. KIF

  82. Xcode 7 UI TESTING

  83. All UI testing

  84. UI Testing Gotchas

  85. Advanced Laziness-Driven development: Adopting laziness techniques from other languges

  86. Android

  87. None
  88. None
  89. Figure out how to take the theory and use it

    in an iOS-friendly way
  90. Caution: Take care that you're bringing things over as supplements.

  91. Don't try to force a new language or platform to

    fit what you already know
  92. Advanced Laziness-Driven development: Writing Your own Laziness-Enhancing Tools

  93. When Should You write Your own tools?

  94. None
  95. (Achtung! shameless self-promotion)

  96. My Experience Writing Tools

  97. Cat2Cat Asset Catalog To Category Instead of writing: [UIImage imageNamed:@"My

    Image Name"]; you can write: [UIImage ac_My_Image_Name];
  98. How is this lazier?

  99. None
  100. XcodeautoBasher

  101. None
  102. in conclusion » Centralize your code, make it easy to

    read, and keep it separated by purpose, so it's easy to fix. » Get rid of stringly-typed code so it's harder to break in the first place. » Use the tools other people have built to enhance your laziness, or build new tools yourself. » Best practices are secretly the lazy way to code.
  103. Questions?

  104. Thank you!

  105. Links » Alcatraz: http://alcatraz.io/ » Cocoa Controls: https://www.cocoacontrols.com/ » Swift

    In Practice: https://developer.apple.com/ videos/play/wwdc2015-411/ » CountableIntEnum: https://gist.github.com/ LoganWright/c8a26b1faf538e40f747 » Swift API Design Guidelines: https://swift.org/ documentation/api-design-guidelines
  106. Code Generation Tools » MOGenerator: https://github.com/rentzsch/ mogenerator » Cat2Cat: https://github.com/vokal/Cat2Cat

    » objc codegenutils: https://github.com/square/objc- codegenutils/
  107. Alcatraz Plugins » https://github.com/vokal/XcodeAutoBasher » https://github.com/onevcat/VVDocumenter-Xcode » https://github.com/trawor/XToDo » https://github.com/neonichu/BBUFullIssueNavigator

    » https://github.com/stefanceriu/SCXcodeMiniMap
  108. image credits » Luca Nebuloni, Pasta with finocciona: https:// www.flickr.com/photos/nebulux/10708289086

    » Tom Bech, Eurasian Wolf: https://www.flickr.com/ photos/viatorius/9358589025 » Michael D Beckwith, The Leeds Library: https:// www.flickr.com/photos/118118485@N05/16438065636/