How can I implement feature toggle in Java from scratch?
Asked Answered
M

2

5

I have a requirement to implement feature toggling in my current project. I have no idea how to implement it from scratch in Java.

I have read the theory behind the feature toggling at various articles related to this topic but I haven't yet seen the implementation tutorial or documentation that describe this in detail for a beginner.

Macgregor answered 29/1, 2018 at 15:36 Comment(2)
Why do you have to implement it from scratch? There are a few good libraries out there already that have done all the heavy lifting for you.Hazard
Not the feature flags from scratch. But actually a project implementing these feature flags. As in a working demo of those along with details.Macgregor
C
6

I would recommend taking a look at some existing implementations to get ideas on how you want your system to behave and fits with your requirements. There is a small list at http://featureflags.io/java-feature-flags/, and poking around the web can probably find more.

In the end, you'll need to consider a few things:

  • Where are feature flags stored
  • How are feature flags applied/determined
  • What kind of deployments/rollouts do you need to support

Edit: From personal experience, Launch Darkly has a pretty cool approach where the clients are loaded with the rules engine for determining flag status, which makes it very fast & resilient to the hosted service going down.

Chromium answered 29/1, 2018 at 15:49 Comment(3)
So basically, its mostly about using the annotations described already in the libraries for this? Of course it comes into effect after we have realise what types of toggles we need in our application.Macgregor
Annotations, or a service + enum values are two extremely common approaches for actually applying them. And correct - the code doing the checking obviously needs to know the specific toggle to check for, so the framework doing the checking needs to be able to handle what to do if asked about a flag that it doesn't know about yetChromium
Thanks for clarification. Darkly actually has some great documentation about this really. Let me try to have a grasp of it.Macgregor
L
2

Have a look at the following projects:

And there's even more listed over at Feature Flags

Leucotomy answered 29/1, 2018 at 15:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.