Feature branches and toggles in a post-GitHub world GOTO Chicago - - PowerPoint PPT Presentation

feature branches and toggles in a post github world
SMART_READER_LITE
LIVE PREVIEW

Feature branches and toggles in a post-GitHub world GOTO Chicago - - PowerPoint PPT Presentation

Feature branches and toggles in a post-GitHub world GOTO Chicago 2017 Sam Newman @gotochi @samnewman Sam Newman & Associates @gotochi @samnewman Sam Newman & Associates (there are no associates) @gotochi @samnewman Building


slide-1
SLIDE 1

Feature branches and toggles in a post-GitHub world

GOTO Chicago 2017 Sam Newman

slide-2
SLIDE 2

@samnewman @gotochi

slide-3
SLIDE 3

@samnewman @gotochi

Sam Newman & Associates

slide-4
SLIDE 4

@samnewman @gotochi

Sam Newman & Associates

(there are no associates)

slide-5
SLIDE 5

@samnewman @gotochi

Sam Newman

Building Microservices

DESIGNING FINE-GRAINED SYSTEMS

slide-6
SLIDE 6

@samnewman @gotochi

2004

slide-7
SLIDE 7

@samnewman @gotochi

slide-8
SLIDE 8

@samnewman @gotochi

slide-9
SLIDE 9

@samnewman @gotochi

to Banbury Oxford Reading High Wycombe London Marylebone to Luton St Albans London St P

Rugby Milton Keynes Central Watford Junction London Euston Bedford

Wolverton Fenny Stratford Bow Brickhill Woburn Sands Aspley Guise Ridgmont Lidlington Watford North Garston Bricket Wood How Wood Park Street St Albans Abbey Millbrook Stewartby Kempston Hardwick Bedford St Johns Bletchley Leighton Buzzard Cheddington Tring Berkhamsted Hemel Hempstead Apsley Kings Langley Bushey Harrow & Wealdstone Wembley Central k

Coventry Leamington Spa Northampton

Long Buckby Coventry Arena

slide-10
SLIDE 10

@samnewman @gotochi

to Banbury Oxford Reading High Wycombe London Marylebone to Luton St Albans London St P

Rugby Milton Keynes Central Watford Junction London Euston Bedford

Wolverton Fenny Stratford Bow Brickhill Woburn Sands Aspley Guise Ridgmont Lidlington Watford North Garston Bricket Wood How Wood Park Street St Albans Abbey Millbrook Stewartby Kempston Hardwick Bedford St Johns Bletchley Leighton Buzzard Cheddington Tring Berkhamsted Hemel Hempstead Apsley Kings Langley Bushey Harrow & Wealdstone Wembley Central k

Coventry Leamington Spa Northampton

Long Buckby Coventry Arena

slide-11
SLIDE 11

@samnewman @gotochi

to Banbury Oxford Reading High Wycombe London Marylebone to Luton St Albans London St P

Rugby Milton Keynes Central Watford Junction London Euston Bedford

Wolverton Fenny Stratford Bow Brickhill Woburn Sands Aspley Guise Ridgmont Lidlington Watford North Garston Bricket Wood How Wood Park Street St Albans Abbey Millbrook Stewartby Kempston Hardwick Bedford St Johns Bletchley Leighton Buzzard Cheddington Tring Berkhamsted Hemel Hempstead Apsley Kings Langley Bushey Harrow & Wealdstone Wembley Central k

Coventry Leamington Spa Northampton

Long Buckby Coventry Arena

slide-12
SLIDE 12

@samnewman @gotochi

to Banbury Oxford Reading High Wycombe London Marylebone to Luton St Albans London St P

Rugby Milton Keynes Central Watford Junction London Euston Bedford

Wolverton Fenny Stratford Bow Brickhill Woburn Sands Aspley Guise Ridgmont Lidlington Watford North Garston Bricket Wood How Wood Park Street St Albans Abbey Millbrook Stewartby Kempston Hardwick Bedford St Johns Bletchley Leighton Buzzard Cheddington Tring Berkhamsted Hemel Hempstead Apsley Kings Langley Bushey Harrow & Wealdstone Wembley Central k

Coventry Leamington Spa Northampton

Long Buckby Coventry Arena

slide-13
SLIDE 13

@samnewman @gotochi

R3

slide-14
SLIDE 14

@samnewman @gotochi

R3

slide-15
SLIDE 15

@samnewman @gotochi

R3 R4

slide-16
SLIDE 16

@samnewman @gotochi

R3 R4

slide-17
SLIDE 17

@samnewman @gotochi

R3 R4

slide-18
SLIDE 18

@samnewman @gotochi

R3 R4

slide-19
SLIDE 19

@samnewman @gotochi

R3 R4

slide-20
SLIDE 20

@samnewman @gotochi

https://www.flickr.com/photos/jubilo/6965626176/

slide-21
SLIDE 21

@samnewman @gotochi

R3-R4 Merge Bug Fix Team

slide-22
SLIDE 22

@samnewman @gotochi

R3-R4 Merge Bug Fix Team

yay

slide-23
SLIDE 23

@samnewman @gotochi

slide-24
SLIDE 24

@samnewman @gotochi

Continuous Integration

slide-25
SLIDE 25

@samnewman @gotochi

slide-26
SLIDE 26

@samnewman @gotochi

slide-27
SLIDE 27

@samnewman @gotochi CI Tool

slide-28
SLIDE 28

@samnewman @gotochi CI Tool

slide-29
SLIDE 29

@samnewman @gotochi CI Tool

slide-30
SLIDE 30

@samnewman @gotochi

slide-31
SLIDE 31

@samnewman @gotochi

slide-32
SLIDE 32

@samnewman @gotochi

slide-33
SLIDE 33

@samnewman @gotochi

slide-34
SLIDE 34

@samnewman @gotochi

  • 1. Validate the integration
slide-35
SLIDE 35

@samnewman @gotochi

  • 1. Validate the integration
slide-36
SLIDE 36

@samnewman @gotochi

  • 2. When the build breaks, fix it!
  • 1. Validate the integration
slide-37
SLIDE 37

@samnewman @gotochi

  • 2. When the build breaks, fix it!
  • 1. Validate the integration
slide-38
SLIDE 38

@samnewman @gotochi

  • 2. When the build breaks, fix it!
  • 1. Validate the integration

slide-39
SLIDE 39

@samnewman @gotochi

  • 2. When the build breaks, fix it!
  • 1. Validate the integration

slide-40
SLIDE 40

@samnewman @gotochi

  • 2. When the build breaks, fix it!
  • 1. Validate the integration

slide-41
SLIDE 41

@samnewman @gotochi

  • 2. When the build breaks, fix it!
  • 3. Integrate daily
  • 1. Validate the integration

slide-42
SLIDE 42

@samnewman @gotochi

R3 R4

slide-43
SLIDE 43

@samnewman @gotochi

R3 R4

slide-44
SLIDE 44

@samnewman @gotochi

R3 R4

slide-45
SLIDE 45

@samnewman @gotochi

R3 R4

slide-46
SLIDE 46

@samnewman @gotochi

Integrate Once A Day

slide-47
SLIDE 47

@samnewman @gotochi

How can you deal with half-finished work?

slide-48
SLIDE 48

@samnewman @gotochi

Option 1:

slide-49
SLIDE 49

@samnewman @gotochi

Option 1:

Wait to check in

slide-50
SLIDE 50

@samnewman @gotochi

Option 2:

slide-51
SLIDE 51

@samnewman @gotochi

Option 2:

Make a branch!

slide-52
SLIDE 52

@samnewman @gotochi

Trunk

slide-53
SLIDE 53

@samnewman @gotochi

Trunk

slide-54
SLIDE 54

@samnewman @gotochi

Trunk F1

slide-55
SLIDE 55

@samnewman @gotochi

Trunk F1

slide-56
SLIDE 56

@samnewman @gotochi

Trunk F1

slide-57
SLIDE 57

@samnewman @gotochi

Trunk F1 F2

slide-58
SLIDE 58

@samnewman @gotochi

Trunk F1 F2

slide-59
SLIDE 59

@samnewman @gotochi

Trunk F1 F2

slide-60
SLIDE 60

@samnewman @gotochi

Trunk F1 F2

slide-61
SLIDE 61

@samnewman @gotochi

Trunk F1 F2

slide-62
SLIDE 62

@samnewman @gotochi

we are deferring integration!

Trunk F1 F2

slide-63
SLIDE 63

@samnewman @gotochi

Pain of merge = fn ( size_of_merge, duration_since_last_merge)

slide-64
SLIDE 64

@samnewman @gotochi

Big merges = commit race!

slide-65
SLIDE 65

@samnewman @gotochi

Merging refactoring is *really* hard

slide-66
SLIDE 66

@samnewman @gotochi

Option 3:

slide-67
SLIDE 67

@samnewman @gotochi

Option 3:

Check in anyway

slide-68
SLIDE 68

@samnewman @gotochi

Option 3:

Check in anyway

err…wat?

slide-69
SLIDE 69

@samnewman @gotochi

Trunk-based development

slide-70
SLIDE 70

@samnewman @gotochi

Everyone integrates into trunk

slide-71
SLIDE 71

@samnewman @gotochi

Trunk

slide-72
SLIDE 72

@samnewman @gotochi

Trunk

slide-73
SLIDE 73

@samnewman @gotochi

integrate often…

Trunk

slide-74
SLIDE 74

@samnewman @gotochi

integrate often…

Trunk

…fast feedback…

slide-75
SLIDE 75

@samnewman @gotochi

integrate often…

Trunk

…fast feedback… …break up merge pain

slide-76
SLIDE 76

@samnewman @gotochi

integrate often…

Trunk

…fast feedback… …break up merge pain err…but what about half-finished features?

slide-77
SLIDE 77

@samnewman @gotochi

Feature Toggles

slide-78
SLIDE 78

@samnewman @gotochi

Feature Toggles

Hide the partially implemented feature in the running system

slide-79
SLIDE 79

@samnewman @gotochi

… super_widget = off …

slide-80
SLIDE 80

@samnewman @gotochi

… super_widget = off … … super_widget = on …

slide-81
SLIDE 81

@samnewman @gotochi

… super_widget = off … … super_widget = on …

super widget!

slide-82
SLIDE 82

@samnewman @gotochi

… super_widget = off … … super_widget = on … $. run -Dsuper_widget=on

super widget!

slide-83
SLIDE 83

@samnewman @gotochi

… super_widget = off … … super_widget = on … $. run -Dsuper_widget=on

super widget!

slide-84
SLIDE 84

@samnewman @gotochi

But what about changes to existing functionality?

slide-85
SLIDE 85

@samnewman @gotochi

slide-86
SLIDE 86

@samnewman @gotochi Hypersonic Persistence

Hypersonic

slide-87
SLIDE 87

@samnewman @gotochi Hypersonic Persistence

Hypersonic Postgres

slide-88
SLIDE 88

@samnewman @gotochi Hypersonic Persistence

Hypersonic Postgres

slide-89
SLIDE 89

@samnewman @gotochi Hypersonic Persistence

Hypersonic Postgres

shipping every two weeks…

slide-90
SLIDE 90

@samnewman @gotochi Hypersonic Persistence Generic SQL Persistence

Hypersonic Postgres

shipping every two weeks…

slide-91
SLIDE 91

@samnewman @gotochi Hypersonic Persistence Persistence Interface Generic SQL Persistence

Hypersonic Postgres

shipping every two weeks…

slide-92
SLIDE 92

@samnewman @gotochi Hypersonic Persistence Persistence Interface Generic SQL Persistence

Hypersonic Postgres

shipping every two weeks…

slide-93
SLIDE 93

@samnewman @gotochi Hypersonic Persistence Persistence Interface Generic SQL Persistence

Hypersonic Postgres

shipping every two weeks…

slide-94
SLIDE 94

@samnewman @gotochi Hypersonic Persistence Persistence Interface Generic SQL Persistence

Hypersonic Postgres

shipping every two weeks…

slide-95
SLIDE 95

@samnewman @gotochi Hypersonic Persistence Persistence Interface Generic SQL Persistence

Hypersonic Postgres

shipping every two weeks…

slide-96
SLIDE 96

@samnewman @gotochi Persistence Interface Generic SQL Persistence

Postgres

shipping every two weeks…

slide-97
SLIDE 97

@samnewman @gotochi

slide-98
SLIDE 98

@samnewman @gotochi

Feature Branching

slide-99
SLIDE 99

@samnewman @gotochi

Feature Branching Branch-by abstraction

slide-100
SLIDE 100

@samnewman @gotochi

Important Rules:

slide-101
SLIDE 101

@samnewman @gotochi

Important Rules:

Use a flag in as few places as possible

slide-102
SLIDE 102

@samnewman @gotochi

Important Rules:

Use a flag in as few places as possible

Remove them once you’re done

slide-103
SLIDE 103

@samnewman @gotochi

Side Benefits:

slide-104
SLIDE 104

@samnewman @gotochi

Side Benefits:

Can be used for A/B testing

slide-105
SLIDE 105

@samnewman @gotochi

Side Benefits:

Can be used for A/B testing

And with some work, canary releasing

slide-106
SLIDE 106

@samnewman @gotochi

https://trunkbaseddevelopment.com

slide-107
SLIDE 107

@samnewman @gotochi

Continuous Delivery Book…

slide-108
SLIDE 108

@samnewman @gotochi

Published in 2011

slide-109
SLIDE 109

@samnewman @gotochi

Treat every check-in as a release candidate

slide-110
SLIDE 110

@samnewman @gotochi

https://www.slideshare.net/jallspaw/ops-metametrics-the-currency-you-pay-for-change-4608108

slide-111
SLIDE 111

@samnewman @gotochi Ops Meta-Metrics - John Allspaw

slide-112
SLIDE 112

@samnewman @gotochi Ops Meta-Metrics - John Allspaw

slide-113
SLIDE 113

@samnewman @gotochi

Integrate often

slide-114
SLIDE 114

@samnewman @gotochi

Integrate often Keep batch size small

slide-115
SLIDE 115

@samnewman @gotochi

Integrate often Keep batch size small Ship often

slide-116
SLIDE 116

@samnewman @gotochi

And there there was Git

slide-117
SLIDE 117

@samnewman @gotochi

slide-118
SLIDE 118

@samnewman @gotochi

Goal

slide-119
SLIDE 119

@samnewman @gotochi

Goal

Merge a patch in less than 3 seconds

slide-120
SLIDE 120

@samnewman @gotochi

Branches much more lightweight

slide-121
SLIDE 121

@samnewman @gotochi

Full local copy of source history

slide-122
SLIDE 122

@samnewman @gotochi

Merging of text is better but…

slide-123
SLIDE 123

@samnewman @gotochi

slide-124
SLIDE 124

@samnewman @gotochi

And then there was GitHub…

slide-125
SLIDE 125

@samnewman @gotochi

2008

slide-126
SLIDE 126

@samnewman @gotochi

https://github.com/blog/3-oh-yeah-there-s-pull-requests-now

slide-127
SLIDE 127

@samnewman @gotochi

https://vimeo.com/2979844

slide-128
SLIDE 128

@samnewman @gotochi

https://vimeo.com/2979844

slide-129
SLIDE 129

@samnewman @gotochi

http://readwrite.com/2011/06/02/github-has-passed-sourceforge/

slide-130
SLIDE 130

@samnewman @gotochi

But PRs use branching!

slide-131
SLIDE 131

@samnewman @gotochi

And then there was gitflow…

slide-132
SLIDE 132

@samnewman @gotochi

slide-133
SLIDE 133

@samnewman @gotochi https://www.flickr.com/photos/hackny/8675049276/

slide-134
SLIDE 134

@samnewman @gotochi Ops Meta-Metrics - John Allspaw

slide-135
SLIDE 135

@samnewman @gotochi

But if I merge in frequently, why do I need GitFlow?

slide-136
SLIDE 136

@samnewman @gotochi

split.io, launch darkly

slide-137
SLIDE 137

@samnewman @gotochi

slide-138
SLIDE 138

@samnewman @gotochi

slide-139
SLIDE 139

@samnewman @gotochi

slide-140
SLIDE 140

@samnewman @gotochi

“Trunk-based development is likely the most controversial practice discussed in this book

slide-141
SLIDE 141

@samnewman @gotochi

“Trunk-based development is likely the most controversial practice discussed in this book

  • Gene Kim, Jez Humble, Patrick Debois & John Willis

[…] However, the data from Puppet Labs’ 2015 State of DevOps Report is clear: trunk-based development predicts higher throughput and better stability, and even higher job satisfaction and lower rates of burnout.“

slide-142
SLIDE 142

@samnewman @gotochi

slide-143
SLIDE 143

@samnewman @gotochi

“We found that having branches or forks with very short lifetimes (less than a day) before being merged into trunk, and less than three active branches in total, are important aspects

  • f continuous delivery, and all contribute to higher
  • performance. So does merging code into trunk or master on a

daily basis. “

  • State Of Devops Report, 2016
slide-144
SLIDE 144

@samnewman @gotochi

So are branches evil?

slide-145
SLIDE 145

@samnewman @gotochi

Integrate often

slide-146
SLIDE 146

@samnewman @gotochi

Integrate often Keep batch size small

slide-147
SLIDE 147

@samnewman @gotochi

Integrate often Keep batch size small Ship often

slide-148
SLIDE 148

@samnewman @gotochi

http://samnewman.io @samnewman Thank You!

Also thanks to Don Clark for the people icons https://commons.wikimedia.org/wiki/File:Gender_neutral.svg CC BY-SA 4.0