Hacker News new | ask | show | jobs
by backslash_16 3691 days ago
Can you expand on this? I'm interested to see how this works in a real code base.

I'm thinking something like an initial (maybe massive) if block in the setup of the application that sets all of the behavior/features by declaring which implementations get set to which interfaces? After this if block, all of the DI stuff is set?

This of course means you need to use a DI framework of some sort.

Using feature flags is something I'm investigating because our current model is a git branch for every feature, and I wonder/fear it only works because we're a small team that has worked together for a while and in the future when we grow this will break down.

1 comments

I was about to say the same thing as your parent. I recently had a nice feature toggle experience using a strategy pattern with DI.

Basically there was one 'if' statement in the DI container configuration code that looked up a config. Basically

if (newPricingStrategy) bind IPricingStrategy to NewPricingStrategyImplementation else bind IPricingStrategy to OldPricingStrategyImplementation