28
Feature Toggles Anand Agrawal

Feature toggles

Embed Size (px)

DESCRIPTION

Feature toggle widely used in industry to release incomplete features and do A/B testing on features. The presentation covers pros and cons of the approach and share some tips and tricks.

Citation preview

Page 1: Feature toggles

Feature Toggles

Anand Agrawal

Page 2: Feature toggles

Feature branches &Continuous Integration

Page 3: Feature toggles

Feature Braches

Trunk

Developer A

Developer B

Page 4: Feature toggles

ProsCode for new feature could not make to

productionNo fear to check-in in branch

ConsMerge hellFear of refactoringDifficult to share code across branches

Page 5: Feature toggles

Continuous Integration

Page 6: Feature toggles

ProsAvoid big mergesEach check-in is production readyContinuously Integrate thorough out the

progress path of the feature Cons

Incomplete feature may go to productionFear to commit code

Page 7: Feature toggles

Then how to do Continuous Integration?

Feature Toggles

Page 8: Feature toggles

What are toggles?

Page 9: Feature toggles

It’s a simple if statement

Page 10: Feature toggles

Feature toggle is a if statement that hides certain execution path

Page 11: Feature toggles

Types of Feature toggle

Release toggles Business toggles

Page 12: Feature toggles

Release Toggles

To hide incomplete feature Short lived Removed as soon as feature is ready Have pre-decided values across

environments (except dev)

Page 13: Feature toggles

Business Toggles

To enable A / B testing Release feature to certain groups of

people to get early feedback Could be enabled or disabled on the fly

Page 14: Feature toggles

Testing the Toggles

Unit TestTest for both conditions i.e. toggle on and off

Integration TestTest with toggle states that are going liveTest with toggle onWith business toggles be smart about what

you want to test than try and test all combinations

Page 15: Feature toggles

Tips and tricks to implement Feature Toggle

Page 16: Feature toggles

In case of building new API end point that is not public facing

No feature toggle needed

Page 17: Feature toggles

In case of creating new model or table

No feature toggle needed

Page 18: Feature toggles

In case of adding a new column in database and exposing it through service

No feature toggle neededMay feature toggle validations

or provide default value

Page 19: Feature toggles

In case of new endpoint that is public facing

Just feature toggle the url

Page 20: Feature toggles

In case of UI component embedded in existing page

Feature toggle the view element

Page 21: Feature toggles

In case of logic change like change the way payment is processed

Feature toggle by abstraction

Page 22: Feature toggles

Things to keep in mind

Don’t try to toggle each and every line of code. Use only where its needed.

Keep the number of toggles under control

Try to create mutually exclusive toggles Clean up release toggles and dead code

Page 23: Feature toggles

Ways to implement toggles Config file Toggle manager for Admin to manage Cookie store … or whatever that makes sense

Page 24: Feature toggles

They are riding on the same boat

Page 25: Feature toggles

Feature Toggle is second best solution. The best solution is to find a way to gradually integrate, without Feature Branches or Feature Toggles.

Martin Fowler

Page 26: Feature toggles

No free lunch

Good test suite (unit and acceptance) Fix or Revert the breaking change

immediately Break down features into smaller stories Break down stories into smaller tech

tasks Think of how to take your code to

production everyday than creating blockers

Page 28: Feature toggles

Questions ?