Top Banner
Don’t Refactor. Rebuild. Kinda. Wouter Lagerweij @wouterla
40

Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)

Feb 21, 2017

Download

Software

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)

Don’t Refactor.Rebuild.

Kinda.

Wouter Lagerweij@wouterla

Page 2: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)
Page 3: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)

16.5M Bikes~1 Bike/person

Page 4: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)
Page 5: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)
Page 6: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)
Page 7: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)
Page 8: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)
Page 9: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)
Page 10: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)
Page 11: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)

● Slow, unreliable unit tests● Slower Selenium tests● Messy, duplicated code● Manual deployments● Production issues

Page 12: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)
Page 13: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)

● TDD● BDD● coding katas● pairing● training w/ Chet● Improve test run time● 100% coverage of new code● refactor in the small (boy scout rule)● refactor in the large (planned improvements)

Page 14: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)

25%1.7% -

2.1% -

Feb

May

unit-test coverage

Page 15: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)
Page 16: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)
Page 17: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)

Rebuild?

Page 18: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)

So...

● Deliver value from day one● Don’t rebuild the same mess● Don’t rebuild using the same process● Don’t rebuild the same functionality

Page 19: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)

In Practice

● Architecture: Strangler Pattern● Process: Continuous Delivery● The First Sprints

Page 20: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)

Architecture: before

DB

request forwebsite A

request forwebsite B

request forwebsite C

request forwebsite D

request forwebsite E

Legacy system

Page 21: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)

DB

request forwebsite A

request forwebsite B

request forwebsite C

request forwebsite D

request forwebsite E

Legacy system

Page 22: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)

DB

website A

Legacy system

Incoming request

New Page

Service

Incoming requestfor new page

Page 23: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)

● 100% unit-test coverage● TDD all the way● All functionality defined by BDD scenarios● Fully automated deployment

● Every push goes to production

Process

Page 25: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)
Page 26: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)

DB

website A

Legacy system

Incoming requestfor job detail page

Job Detail Page

Job Service

Incoming requestfor other pages

Page 27: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)

Sprint 1

Page 28: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)

Sprint 1: Proxy

Goal:

Get a new front-end component up that proxies all traffic to the old system but serves ‘hello world’ if we ask nicely.

Page 29: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)

Sprint 1: Proxy● Create a new environment, in this case on amazon’s AWS● Create Ansible scripts to provision a basic infrastructure:

○ jenkins○ sonar○ docker nodes for test, acceptance and production

● Set up a VPN to the existing (hosted somewhere else) environment● Create a new codebase for a (php, symfony) component● Create build scripts for the new component● Create a hello world page for the url that pointed to the job detail page● Create a proxy so that all calls would be delegated to the old system (apache vhost.conf)● Create a feature toggle so we could override the proxy based on a cookie (apache vhost.conf)● Package our new component as a Docker image, and figure out how to deploy it● Use a docker registry to store and version out deployment packages ● Create Jenkins Job Builder configuration to set-up a delivery pipeline for our new web front end● Create a basic smoke test for the component to check successful deployment in the pipeline● Set-up the AWS loadbalancers for all the environments ● Make sure newrelic could be configured on all our nice new Docker containers● Route all traffic for our first website through our new infrastructure

Page 30: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)

Sprint 1: Proxy● Create a new environment, in this case on amazon’s AWS● Create Ansible scripts to provision a basic infrastructure:

○ jenkins○ sonar○ docker nodes for test, acceptance and production

● Set up a VPN to the existing (hosted somewhere else) environment● Create a new codebase for a (php, symfony) component● Create build scripts for the new component● Create a hello world page for the url that pointed to the job detail page● Create a proxy so that all calls would be delegated to the old system (apache vhost.conf)● Create a feature toggle so we could override the proxy based on a cookie (apache vhost.conf)● Package our new component as a Docker image, and figure out how to deploy it● Use a docker registry to store and version out deployment packages ● Create Jenkins Job Builder configuration to set-up a delivery pipeline for our new web front end

component● Set-up the AWS loadbalancers for all the environments ● Make sure newrelic could be configured on all our nice new Docker containers● Route all traffic for our first website through our new infrastructure

Page 31: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)
Page 32: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)

Sprint 2: Detail Page

Goal:

Get a fully functional Job Detail Page replacement working behind the feature toggle

Page 33: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)

Sprint 2: Detail Page● Create Job Service component, including full pipeline

Page 34: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)

DB

website A

Legacy system

Incoming requestfor job detail page

Job Detail Page

Job Service

Incoming requestfor other pages

Page 35: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)

Sprint 2: Detail Page● Create Job Service component, including full pipeline● Database access to old system’s DB● Unit testing build steps for php● Sonar (static analysis) deployment and build steps ● Contract test for Job Service● Client library for Job Service● Acceptance scenarios for job detail functionality● Unit testing build steps for javascript● Sonar setup for javascript● Implement Just Enough to Read a Job● Create a nice looking front-end...

Page 36: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)

Done?

Page 37: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)

In one month

● legacy system● few tests● manual deploys● 1 release per week● timid team

● decoupled services● 100% coverage● full automation● 30 releases per day● courage

Page 38: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)
Page 39: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)

Problems

Page 40: Don't refactor. rebuild. kinda. (Agile 2015, Washington DC)

@wouterlaWouter Lagerweij

Thank You!