Building for Open-Source

D200a17dd269fd4001bacb11662dab4b?s=47 Kyle Fuller
September 19, 2014

Building for Open-Source

D200a17dd269fd4001bacb11662dab4b?s=128

Kyle Fuller

September 19, 2014
Tweet

Transcript

  1. BUILDING FOR OPEN-SOURCE @ KYLE FULLER

  2. None
  3. WHAT IS OPEN- SOURCE?

  4. "source code that is made freely available and may be

    redistributed and modified."
  5. WHO USES OPEN-SOURCE LIBRARIES?

  6. CONTRIBUTED BACK TO AN OPEN-SOURCE PROJECT?

  7. CREATED AN OPEN- SOURCE PROJECT FROM SCRATCH?

  8. BUILDING FOR Open SOURCE

  9. BUILDING COMPONENTS

  10. GETTING STARTED with OPEN-SOURCE

  11. I WANT TO EXTEND UIALERTVIEW

  12. TO ADD BLOCKS

  13. WHERE TO BEGIN?

  14. HAS SOMEONE DONE THIS BEFORE?

  15. None
  16. 21 RESULTS

  17. CAN I USE ONE OF THESE INSTEAD?

  18. HOW MIGHT THE API LOOK?

  19. README

  20. RDD Readme DRIVEN DEVELOPMENT

  21. KFLAlertView ============ Block-based extension for UIAlertView.

  22. INTERFACE DESIGN

  23. let alertView = AlertView("Directions") alertView.addButton("Maps") { openURL("maps:directions") } alertView.addButton("CityMapper") {

    openURL("citymapper:directions") }
  24. class AlertView : UIAlertView { init(title:String message:String?) func addButton(title:String, handler:(()

    -> ())) }
  25. PDD Playground DRIVEN DEVELOPMENT

  26. // Playground - noun: a place where people can play

    import UIKit class AlertView : UIAlertView { init(title:String, message:String?) { super.init(title: title, message: message, delegate: nil, cancelButtonTitle: nil) } required init(coder decoder: NSCoder) { super.init(coder: decoder) } func addButton(title: String, handler:(() -> ())) { } }
  27. let alertView = AlertView("Directions") alertView.addButton("Maps") { // Open in the

    maps app } alertView.show()
  28. class UIAlertView : UIView { var cancelButtonIndex: Int }

  29. class AlertView : UIAlertView { func addCancelButton(title:String, handler:(() -> ()))

    }
  30. WRITING THE CODE

  31. LICENSE

  32. BSD OR MIT

  33. OPENSOURCE.ORG/LICENSES

  34. TESTING

  35. TRAVIS-CI

  36. None
  37. None
  38. COVERALLS

  39. None
  40. None
  41. None
  42. SWIFT COVERAGE REPORTS

  43. RADAR://17450338

  44. DOCUMENTATION COVERAGE

  45. None
  46. $ pod lib docstats 2 tokens, 100% documented

  47. $ pod lib docstats WARN | NSAttributedString+CCLFormat.h@13: Description for parameter

    '...' missing for +[NSAttributedString(CCLFormat) attributedStringWithFormat:]! WARN | NSAttributedString(CCLFormat) is not documented! 2 tokens, 50% documented
  48. WRITING THE CODE

  49. THE ZEN OF PYTHON TIM PETERS

  50. $ python -c 'import this'

  51. EXPLICIT IS IS BETTER THAN IMPLICIT

  52. SIMPLE IS BETTER THAN COMPLEX

  53. READABILITY COUNTS

  54. if(JK_EXPECT_F(ullv < 10ULL)) { *--aptr = ullv + '0'; }

    else { while(JK_EXPECT_T(ullv > 0ULL)) { *--aptr = (ullv % 10ULL) + '0'; ullv /= 10ULL; NSCParameterAssert(aptr > anum); } }
  55. PUBLIC INTERFACE

  56. IMPLEMENTATION

  57. ERRORS SHOULD NEVER PASS SILENTLY

  58. UNLESS EXPLICITLY SILENCED

  59. - (void)read { open("foo", 0); malloc(); read(); }

  60. - (NSError *)read { if (!open("foo", 0)) { return error;

    } if (!malloc()) { return error; } if (!read()) { return error; } }
  61. IF THE IMPLEMENTATION IS HARD TO EXPLAIN, IT'S A BAD

    IDEA.
  62. UNLESS YOU HAVE A VALID REASON

  63. TRUST NO ONE

  64. PEOPLE WILL ABUSE YOUR API

  65. MOSTLY ACCIDENTALLY

  66. - (void)enqueueRequest:(NSURLRequest *)request { NSParameterAssert(request != nil); // What if

    the request was a mutable request? [request copy] }
  67. func enqueueRequest(request:NSURLRequest) { }

  68. DON'T EXPOSE YOUR INTERNAL IMPLEMENTATION

  69. DISTRIBUTION

  70. COCOAPODS

  71. COCOAPODS IS MORE THAN A TOOL

  72. COCOAPODS IS AN ECOSYSTEM

  73. EVEN IF YOU DON'T USE COCOAPODS

  74. None
  75. $ POD TRY <URL | POD>

  76. KEEP IT LEAN

  77. BREAK IT DOWN INTO LOGICAL COMPONENTS

  78. AFNETWORKING ▸ Serialization ▸ Security ▸ Reachability ▸ NSURLConnection ▸

    NSURLSession ▸ UIKit
  79. pod 'AFNetworking/UIKit'

  80. SUBSPEC ALL THE THINGS

  81. METADATA

  82. None
  83. WHAT DOES THIS DO?

  84. None
  85. UHHH...

  86. DESCRIBE WHAT IT DOES

  87. None
  88. None
  89. SCREENSHOTS

  90. None
  91. SEMANTIC VERSIONING

  92. None
  93. MAJOR.MINOR.PATCH

  94. MAJOR VERSION WHEN YOU MAKE INCOMPATIBLE API CHANGES

  95. MINOR VERSION WHEN YOU ADD FUNCTIONALITY IN A BACKWARDS- COMPATIBLE

    MANNER
  96. PATCH VERSION WHEN YOU MAKE BACKWARDS-COMPATIBLE BUG FIXES

  97. COMMUNITY

  98. None
  99. None
  100. DON'T GET FRUSTRATED

  101. OPEN-SOURCE ALL THE THINGS

  102. @ KYLE FULLER