Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Feature Toggles

Feature Toggles

When you develop in a fast cycle and want to continuously deploy or when you have a project with lots of customer specific configurations feature toggles are a must and you probably use the simplest one `if () then {}`. When you switch between features in your code you will accumulate technical debt fast and if you don't watch out it will turn into a monster. I will show you how to tame the beast that is feature toggling by showing good practices to introduce more complex toggle conditions, how to separate new and old behaviour and how to easily get rid of them when you don't need them.

Denis Brumann

May 12, 2017
Tweet

More Decks by Denis Brumann

Other Decks in Programming

Transcript

  1. Feature Toggles Denis Brumann
 denis.brumann@sensiolabs.de Twitter: @dbrumann phpday 2017 Slides:

    https://speakerdeck.com/dbrumann/feature-toggles Code: https://github.com/dbrumann/toggle-demo
  2. None
  3. None
  4. None
  5. None
  6. None
  7. None
  8. None
  9. None
  10. None
  11. None
  12. None
  13. None
  14. public function hasValidShopLocation() { $location = $this->getLocation(); return ( $location->isValid()

    && (get_class($location) !== CityLocation::class) && !($location instanceof NullLocation) && !($location instanceof VendorCustomLocation) && !( $location instanceof GpsLocation && $this->locationFeatureHandler->gpsLocationNeedToHaveStreetToBeValid() && $location->getStreet() === null ) ); }
  15. None
  16. None
  17. None
  18. None
  19. None
  20. None
  21. None
  22. None
  23. None
  24. None
  25. None
  26. None
  27. Look back Did we need toggling in previous features?
 How

    did we solve them? Plan ahead Do we need to toggle this in dev/qa/production?
 How long will this toggle stay in our code?
  28. Question existing toggles Do complex conditions make the code hard

    to read?
 Do we often have to change the context for the toggle?
  29. Remove toggles Even better: avoid writing them in the first

    place
  30. None
  31. None
  32. None
  33. Thank You https://joind.in/talk/18529