Slide 1

Slide 1 text

BUILDING FOR OPEN-SOURCE @ KYLE FULLER

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

WHAT IS OPEN- SOURCE?

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

WHO USES OPEN-SOURCE LIBRARIES?

Slide 6

Slide 6 text

CONTRIBUTED BACK TO AN OPEN-SOURCE PROJECT?

Slide 7

Slide 7 text

CREATED AN OPEN- SOURCE PROJECT FROM SCRATCH?

Slide 8

Slide 8 text

BUILDING FOR Open SOURCE

Slide 9

Slide 9 text

BUILDING COMPONENTS

Slide 10

Slide 10 text

GETTING STARTED with OPEN-SOURCE

Slide 11

Slide 11 text

I WANT TO EXTEND UIALERTVIEW

Slide 12

Slide 12 text

TO ADD BLOCKS

Slide 13

Slide 13 text

WHERE TO BEGIN?

Slide 14

Slide 14 text

HAS SOMEONE DONE THIS BEFORE?

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

21 RESULTS

Slide 17

Slide 17 text

CAN I USE ONE OF THESE INSTEAD?

Slide 18

Slide 18 text

HOW MIGHT THE API LOOK?

Slide 19

Slide 19 text

README

Slide 20

Slide 20 text

RDD Readme DRIVEN DEVELOPMENT

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

INTERFACE DESIGN

Slide 23

Slide 23 text

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

Slide 24

Slide 24 text

class AlertView : UIAlertView { init(title:String message:String?) func addButton(title:String, handler:(() -> ())) }

Slide 25

Slide 25 text

PDD Playground DRIVEN DEVELOPMENT

Slide 26

Slide 26 text

// 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:(() -> ())) { } }

Slide 27

Slide 27 text

let alertView = AlertView("Directions") alertView.addButton("Maps") { // Open in the maps app } alertView.show()

Slide 28

Slide 28 text

class UIAlertView : UIView { var cancelButtonIndex: Int }

Slide 29

Slide 29 text

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

Slide 30

Slide 30 text

WRITING THE CODE

Slide 31

Slide 31 text

LICENSE

Slide 32

Slide 32 text

BSD OR MIT

Slide 33

Slide 33 text

OPENSOURCE.ORG/LICENSES

Slide 34

Slide 34 text

TESTING

Slide 35

Slide 35 text

TRAVIS-CI

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

COVERALLS

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

SWIFT COVERAGE REPORTS

Slide 43

Slide 43 text

RADAR://17450338

Slide 44

Slide 44 text

DOCUMENTATION COVERAGE

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

$ pod lib docstats 2 tokens, 100% documented

Slide 47

Slide 47 text

$ 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

Slide 48

Slide 48 text

WRITING THE CODE

Slide 49

Slide 49 text

THE ZEN OF PYTHON TIM PETERS

Slide 50

Slide 50 text

$ python -c 'import this'

Slide 51

Slide 51 text

EXPLICIT IS IS BETTER THAN IMPLICIT

Slide 52

Slide 52 text

SIMPLE IS BETTER THAN COMPLEX

Slide 53

Slide 53 text

READABILITY COUNTS

Slide 54

Slide 54 text

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); } }

Slide 55

Slide 55 text

PUBLIC INTERFACE

Slide 56

Slide 56 text

IMPLEMENTATION

Slide 57

Slide 57 text

ERRORS SHOULD NEVER PASS SILENTLY

Slide 58

Slide 58 text

UNLESS EXPLICITLY SILENCED

Slide 59

Slide 59 text

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

Slide 60

Slide 60 text

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

Slide 61

Slide 61 text

IF THE IMPLEMENTATION IS HARD TO EXPLAIN, IT'S A BAD IDEA.

Slide 62

Slide 62 text

UNLESS YOU HAVE A VALID REASON

Slide 63

Slide 63 text

TRUST NO ONE

Slide 64

Slide 64 text

PEOPLE WILL ABUSE YOUR API

Slide 65

Slide 65 text

MOSTLY ACCIDENTALLY

Slide 66

Slide 66 text

- (void)enqueueRequest:(NSURLRequest *)request { NSParameterAssert(request != nil); // What if the request was a mutable request? [request copy] }

Slide 67

Slide 67 text

func enqueueRequest(request:NSURLRequest) { }

Slide 68

Slide 68 text

DON'T EXPOSE YOUR INTERNAL IMPLEMENTATION

Slide 69

Slide 69 text

DISTRIBUTION

Slide 70

Slide 70 text

COCOAPODS

Slide 71

Slide 71 text

COCOAPODS IS MORE THAN A TOOL

Slide 72

Slide 72 text

COCOAPODS IS AN ECOSYSTEM

Slide 73

Slide 73 text

EVEN IF YOU DON'T USE COCOAPODS

Slide 74

Slide 74 text

No content

Slide 75

Slide 75 text

$ POD TRY

Slide 76

Slide 76 text

KEEP IT LEAN

Slide 77

Slide 77 text

BREAK IT DOWN INTO LOGICAL COMPONENTS

Slide 78

Slide 78 text

AFNETWORKING ▸ Serialization ▸ Security ▸ Reachability ▸ NSURLConnection ▸ NSURLSession ▸ UIKit

Slide 79

Slide 79 text

pod 'AFNetworking/UIKit'

Slide 80

Slide 80 text

SUBSPEC ALL THE THINGS

Slide 81

Slide 81 text

METADATA

Slide 82

Slide 82 text

No content

Slide 83

Slide 83 text

WHAT DOES THIS DO?

Slide 84

Slide 84 text

No content

Slide 85

Slide 85 text

UHHH...

Slide 86

Slide 86 text

DESCRIBE WHAT IT DOES

Slide 87

Slide 87 text

No content

Slide 88

Slide 88 text

No content

Slide 89

Slide 89 text

SCREENSHOTS

Slide 90

Slide 90 text

No content

Slide 91

Slide 91 text

SEMANTIC VERSIONING

Slide 92

Slide 92 text

No content

Slide 93

Slide 93 text

MAJOR.MINOR.PATCH

Slide 94

Slide 94 text

MAJOR VERSION WHEN YOU MAKE INCOMPATIBLE API CHANGES

Slide 95

Slide 95 text

MINOR VERSION WHEN YOU ADD FUNCTIONALITY IN A BACKWARDS- COMPATIBLE MANNER

Slide 96

Slide 96 text

PATCH VERSION WHEN YOU MAKE BACKWARDS-COMPATIBLE BUG FIXES

Slide 97

Slide 97 text

COMMUNITY

Slide 98

Slide 98 text

No content

Slide 99

Slide 99 text

No content

Slide 100

Slide 100 text

DON'T GET FRUSTRATED

Slide 101

Slide 101 text

OPEN-SOURCE ALL THE THINGS

Slide 102

Slide 102 text

@ KYLE FULLER