When in doubt, push with flags

Yogisha,boolean

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: