YanivHer
YanivHer

Reputation: 133

Using Feature Flags while registering the dependency

I'm new to using Feature Flags.

In a development team with 5-7 developers, where each possibly working on different Feature, merging to master/main every PR (Trunk) on nearly daily routine, how can I prevent master branch code eventually looks like Spaghetti with methods having

do something
if flag1 enabled then..
   do something
if flag2 enabled then..
   do something
if flag3 enabled then..
   do something
..
..

I thought of using the flags while registering to the IoC like:

if flag1 register Implementation_X1 to Interface_X else register Implementation_X2
if flag2 register Implementation_Y1 to Interface_Y else register Implementation_Y2
..
..

This will allow me to handle all conditions of Feature Flags in single place (or at least where resolving the dependencies), will prevent code being "dirty" with multiple conditions that are not related to actual business logic flow, unit tests won't know on the Feature Flags as they will be covering each implementation separately.

Thing is, I can't find any article explaining this way for using Feature Flags so I thought I might be missing something.

Upvotes: 1

Views: 570

Answers (0)

Related Questions