When in doubt, push with flags
When in doubt, push with flags
There was a situation today. Clients wanted contact sync feature before but they changed their mind. They wanted to remove the feature for now. They were quite fickle about it.
Since, just commenting or completely removing the code may not be good for future, I was introduced to feature flags. I was told, "When in doubt, push your changes with flags". This way if client changed their mind, the feature can be just changed to true or false. This way there is no fear that another developer may remove the commented code or a need to search back in history if removed from the file.
A peek into what I did today:
const showSyncContacts = false;
const renderHeader = useCallback(
() => (
<>
<Filters
type={type}
setType={setType}
containerStyle={renderAlphabetScroll && styles.spacingRightFilters}
/>
<Search
containerStyle={[
renderAlphabetScroll && styles.spacingRight,
styles.search,
]}
/>
{showSyncContacts ? (
<SyncContacts permission={permission} setPermission={setPermission} />
) : null}
</>
),
[type, renderAlphabetScroll, permission, showSyncContacts],
);Yogisha Opinions:
- Why push it with flags? Isn't it unnecessary? There is git. You can just find the changes in git history. If there is proper commit messages searching it won't take a lot of time.
- What if the clients never want the feature at all? Then wouldn't it be just hanging on the codebase until another person comes to clean it later?