Published on June 28, 2014
Trunk Based DevelopmentTrunk Based Development Dutch PHP ConferenceDutch PHP Conference 2014-06-282014-06-28
Gordon OheimGordon Oheim Senior Craftsman, PHP Documentor,Senior Craftsman, PHP Documentor, Stack Overflow Contributor & Moderator,Stack Overflow Contributor & Moderator, AgilistAgilist →→ http://twitter.com/go_ohhttp://twitter.com/go_oh →→ http://about.me/goohhttp://about.me/gooh →→ email@example.com@php.net
Before we start …Before we start …
Six months ago …Six months ago …
AdvantagesAdvantages ● Easy to understand when used properlyEasy to understand when used properly ● Branches document Sprints/FeaturesBranches document Sprints/Features ● Isolated development cannot break masterIsolated development cannot break master branchbranch
ProblemsProblems ● assumes Sprints end as plannedassumes Sprints end as planned ● rogue branches might be impossible to mergerogue branches might be impossible to merge ● requires more communication about what wasrequires more communication about what was merged yetmerged yet ● merge conflicts are postponedmerge conflicts are postponed ● merge conflicts are more expensivemerge conflicts are more expensive
Welcome to Merge HellWelcome to Merge Hell
Trunk Based Development to the rescue Image: https://commons.wikimedia.org/wiki/File:Placeholder_male_superhero_c.png (CC SA 3.0)
Trunk Based DevelopmentTrunk Based Development ● everyone commits to master at least once per dayeveryone commits to master at least once per day ● remote branches are only made for releasesremote branches are only made for releases ● developers may use local branchesdevelopers may use local branches ● hotfixes are also committed to masterhotfixes are also committed to master ● hotfixes are cherry picked into supported releaseshotfixes are cherry picked into supported releases ● only Release Managers may branch releaseonly Release Managers may branch release branchesbranches
AdvantagesAdvantages ● leanlean ● can release at any timecan release at any time ● merge problems surface earlymerge problems surface early ● merge problems are smallermerge problems are smaller ● release branches are cheaprelease branches are cheap
ProblemsProblems ● Branches no longer document featuresBranches no longer document features ● Needs a way to hide/disable unfinished workNeeds a way to hide/disable unfinished work ● Requires additional care with db changesRequires additional care with db changes ● Requires OOD knowledgeRequires OOD knowledge
Branch by AbstractionBranch by Abstraction "Branch by Abstraction" is a technique for making a large-"Branch by Abstraction" is a technique for making a large- scale change to a software system in gradual way thatscale change to a software system in gradual way that allows you to release the system regularly while theallows you to release the system regularly while the change is still in-progress.change is still in-progress. - Martin Fowler- Martin Fowler
In a nutshellIn a nutshell ● modularity through design not through VCSmodularity through design not through VCS ● add an abstraction over any code you are going to change in aadd an abstraction over any code you are going to change in a featurefeature ● new features are added through Adapters and Interfacesnew features are added through Adapters and Interfaces ● production code keeps old implementations while feature isproduction code keeps old implementations while feature is incompleteincomplete ● development code uses the new implementationsdevelopment code uses the new implementations ● when the feature is ready, the new implementations arewhen the feature is ready, the new implementations are rolled outrolled out
Feature TogglesFeature Toggles ● features are hidden until readyfeatures are hidden until ready ● hides features at the entry pointshides features at the entry points ● easy to configure via config fileeasy to configure via config file ● easy to implement with a small POPOeasy to implement with a small POPO ● can be tailored to specific user groupscan be tailored to specific user groups ● bonus:bonus: allows for easy A/B testingallows for easy A/B testing
Feature Toggles at MVSFeature Toggles at MVS
Database ChangesDatabase Changes ● all changes to the database need to beall changes to the database need to be backwards compatiblebackwards compatible ● one statement per migrationone statement per migration ● migrations should be transactionalmigrations should be transactional ● needs to be integrated into the build processneeds to be integrated into the build process (DBDeploy, Liquibase, …)(DBDeploy, Liquibase, …)
Any Questions so far?Any Questions so far?
Example 1 - Migrate CodeExample 1 - Migrate Code Objective: replace a legacy component with aObjective: replace a legacy component with a newer componentnewer component
Current CodeCurrent Code
Step One: Decouple theStep One: Decouple the implementationimplementation
ProTipProTip ● In PHPStorm you can right-click class code andIn PHPStorm you can right-click class code and select Refactor Extract Interface→ →select Refactor Extract Interface→ → ● If your IDE doesn't support Extract Interface,If your IDE doesn't support Extract Interface, try https://github.com/gooh/InterfaceDistillertry https://github.com/gooh/InterfaceDistiller
Step Two: Change all consumersStep Two: Change all consumers to use the Interfaceto use the Interface
Step Three: Add feature toggleStep Three: Add feature toggle
Step Four: Add new componentStep Four: Add new component
Step Five: CleanupStep Five: Cleanup ● remove the toggle from bootstrapremove the toggle from bootstrap ● optional: remove the interface againoptional: remove the interface again ● Done o/Done o/
Example 2: Change APIExample 2: Change API Objective: adapt a new API graduallyObjective: adapt a new API gradually
Change API - SetupChange API - Setup
Change API: isolate the old APIChange API: isolate the old API
Change API: fading outChange API: fading out
Change API: cleanupChange API: cleanup ● when ready, remove the old API codewhen ready, remove the old API code ● run your tests to make sure it worksrun your tests to make sure it works ● remove the Migration Adapter from bootstrapremove the Migration Adapter from bootstrap ● inject the component with the new API onlyinject the component with the new API only ● done o/done o/
Bonus: Using a VerifyBonus: Using a Verify Objective: harden against failuresObjective: harden against failures
In a nutshellIn a nutshell ● Verify adds additional safety to the migrationVerify adds additional safety to the migration ● fail fast and tell you where at runtimefail fast and tell you where at runtime ● is basically a Runtime Assertionis basically a Runtime Assertion ● isis NOTNOT a replacement for your test QAa replacement for your test QA
Verify: ImplementationVerify: Implementation
Questions?Questions? Last Chance!Last Chance!
ReferencesReferences ● http://paulhammant.com/2013/04/05/what-is-trunk-based-developmenthttp://paulhammant.com/2013/04/05/what-is-trunk-based-development ● http://paulhammant.com/blog/branch_by_abstraction.htmlhttp://paulhammant.com/blog/branch_by_abstraction.html ● http://paulhammant.com/2011/05/13/avoid-big-bang-for-branch-by-abstraction/http://paulhammant.com/2011/05/13/avoid-big-bang-for-branch-by-abstraction/ ● http://continuousdelivery.com/2011/05/make-large-scale-changes-incrementally-with-http://continuousdelivery.com/2011/05/make-large-scale-changes-incrementally-with- branch-by-abstraction/branch-by-abstraction/ ● http://c2.com/cgi/wiki?BranchByAbstractionhttp://c2.com/cgi/wiki?BranchByAbstraction ● http://martinfowler.com/bliki/FeatureToggle.htmlhttp://martinfowler.com/bliki/FeatureToggle.html ● http://martinfowler.com/bliki/BranchByAbstraction.htmlhttp://martinfowler.com/bliki/BranchByAbstraction.html ● http://www.stephen-smith.co.uk/application-pattern-verify-branch-by-abstraction/http://www.stephen-smith.co.uk/application-pattern-verify-branch-by-abstraction/ ● http://dev.jimdo.com/2013/05/03/software-migration-strategies/http://dev.jimdo.com/2013/05/03/software-migration-strategies/ ● http://java.dzone.com/articles/application-pattern-verifyhttp://java.dzone.com/articles/application-pattern-verify ● http://www.whitewashing.de/2013/12/05/feature_flags_and_doctrine_entities.htmlhttp://www.whitewashing.de/2013/12/05/feature_flags_and_doctrine_entities.html ● http://abhishek-tiwari.com/post/decoupling-deployment-and-release-feature-toggleshttp://abhishek-tiwari.com/post/decoupling-deployment-and-release-feature-toggles
Presentación que realice en el Evento Nacional de Gobierno Abierto, realizado los ...
In this presentation we will describe our experience developing with a highly dyna...
Presentation to the LITA Forum 7th November 2014 Albuquerque, NM
Un recorrido por los cambios que nos generará el wearabletech en el futuro
Um paralelo entre as novidades & mercado em Wearable Computing e Tecnologias Assis...
OK, so classically “Mainline” is a synonym of trunk, and for trunk-based-development people have been using “mainline” to describe that too.
Google’s Published talks/info. My knowledge about how Google developed software ended in 2009. They have talked publicly a number of times on the topic ...
Trunk Based Development minimises development costs and risk Always Agile Consulting. Agility ... Organisation Pattern: Trunk Based Development.
At Snap, we practice trunk-based development (TBD) to develop our hosted CI product and so do most consulting projects at ThoughtWorks where we work.
Paul Hammant of ThoughtWorks runs through the history of the 'Trunk-based Development' branching model, its modern usage in big enterprises, and how ...
Trunk Based Development is a version control strategy in which developers commit their changes to the shared trunk of a source code repository with minimal ...
About Trunk Based Development. It is a branching model that promotes avoid shared development branches. ... All developers working on a single shared trunk;
I’m going to try to explain the alternatives for Trunk Based Development (TBD) in terms of branch layout. There’s few different styles, that different ...
Discover how to optimize your DevOps workflows with our cloud-based automated testing infrastructure, brought to you in partnership with Sauce Labs. It ...