{ "uuid": [ { "value": "0a4f05ae-4240-476b-bb57-bcf3d3a598a3" } ], "langcode": [ { "value": "en" } ], "type": [ { "target_id": "daily_email", "target_type": "node_type", "target_uuid": "8bde1f2f-eef9-4f2d-ae9c-96921f8193d7" } ], "revision_timestamp": [ { "value": "2025-05-11T09:00:01+00:00" } ], "revision_uid": [ { "target_type": "user", "target_uuid": "b8966985-d4b2-42a7-a319-2e94ccfbb849" } ], "revision_log": [], "status": [ { "value": true } ], "uid": [ { "target_type": "user", "target_uuid": "b8966985-d4b2-42a7-a319-2e94ccfbb849" } ], "title": [ { "value": "Don't branch, use feature toggles" } ], "created": [ { "value": "2025-02-20T00:00:00+00:00" } ], "changed": [ { "value": "2025-05-11T09:00:01+00:00" } ], "promote": [ { "value": false } ], "sticky": [ { "value": false } ], "default_langcode": [ { "value": true } ], "revision_translation_affected": [ { "value": true } ], "path": [ { "alias": "\/daily\/2025\/02\/20\/toggles", "langcode": "en" } ], "body": [ { "value": "\n

If feature branches cause conflicts<\/a>, what is the alternative?<\/p>\n\n

Don't branch.<\/p>\n\n

Keep all changes on a single branch and avoid merge conflicts between branches by not having branches.<\/p>\n\n

But how can you avoid releasing changes before they are ready?<\/p>\n\n

You can have a local branch with your changes that you don't push and rebase locally, but then you're not doing continuous integration<\/a> and you're just as likely to get conflicts and have incompatible code.<\/p>\n\n

One of the main benefits of trunk-based development, where everything is on a single branch, is that everyone's work always works together.<\/p>\n\n

The better option is to use feature toggles (aka feature flags).<\/p>\n\n

Wrapping code in feature toggles separates deploying the code from releasing the feature.<\/p>\n\n

The code can be released, but the feature isn't active until the toggle is enabled.<\/p>\n\n

This means everyone can work on the same branch and continuously deploy changes whilst being selective about the features that are visible to the end users.<\/p>\n\n

If you have multiple environments, the same code can be used with different toggles enabled to allow for testing different features.<\/p>\n\n

Then, once the feature is ready to be enabled, there is no deployment needed.<\/p>\n\n

The code is already there - it just needs to be enabled.<\/p>\n\n

For Drupal, there is a Feature Toggle module<\/a> and an extension that I wrote<\/a> that make it easy to use and manage feature toggles by just logging into the admin UI and selecting the active toggles you want.<\/p>\n\n

And, if an issue is discovered, it can also be easily disabled without needing to roll back to the previous version<\/a>.<\/p>\n\n ", "format": "full_html", "processed": "\n

If feature branches cause conflicts<\/a>, what is the alternative?<\/p>\n\n

Don't branch.<\/p>\n\n

Keep all changes on a single branch and avoid merge conflicts between branches by not having branches.<\/p>\n\n

But how can you avoid releasing changes before they are ready?<\/p>\n\n

You can have a local branch with your changes that you don't push and rebase locally, but then you're not doing continuous integration<\/a> and you're just as likely to get conflicts and have incompatible code.<\/p>\n\n

One of the main benefits of trunk-based development, where everything is on a single branch, is that everyone's work always works together.<\/p>\n\n

The better option is to use feature toggles (aka feature flags).<\/p>\n\n

Wrapping code in feature toggles separates deploying the code from releasing the feature.<\/p>\n\n

The code can be released, but the feature isn't active until the toggle is enabled.<\/p>\n\n

This means everyone can work on the same branch and continuously deploy changes whilst being selective about the features that are visible to the end users.<\/p>\n\n

If you have multiple environments, the same code can be used with different toggles enabled to allow for testing different features.<\/p>\n\n

Then, once the feature is ready to be enabled, there is no deployment needed.<\/p>\n\n

The code is already there - it just needs to be enabled.<\/p>\n\n

For Drupal, there is a Feature Toggle module<\/a> and an extension that I wrote<\/a> that make it easy to use and manage feature toggles by just logging into the admin UI and selecting the active toggles you want.<\/p>\n\n

And, if an issue is discovered, it can also be easily disabled without needing to roll back to the previous version<\/a>.<\/p>\n\n ", "summary": null } ] }