JulienCorb
So I am building a feature flag solution in my company. This aims at hiding/changing the results of some user actions depending on wether some flags are set.
The flags will be saved in the DB. I can’t change that.
My question is simple: should I allow the use of feature flags in the core of my app? Or should I only allow them to be used in the interface?
My guess is that my core should be agnostic from flags but after all, feature flags are part of the business logic, aren’t they?
Example : Should I use flags like this (without them in the core):
def index(conn, _params) do
my_resource = case FeatureFlag.enabled?("my_flag", get_session(conn)) do
true -> MyAppCore.new_implementation
false -> MyAppCore.old_implementation
end
render(conn, "index.html", resource: my_resource)
end
Or with flags used in the core:
def index(conn, _params) do
my_resource = MyAppCore.my_implementation(get_session(conn))
render(conn, "index.html", resource: my_resource)
end
function in the context :
def my_implementation(session) do
my_resource = case FeatureFlag.enabled?("my_flag", session) do
true -> new_implementation
false -> old_implementation
end
end
Trending in Discussions
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
New
The obligatory hello world thread!
Who are you and where are you from? :stuck_out_tongue:
New
I want to open this thread for you all to discuss and help those who really like Ash but are still hesitant to use it in a real project. ...
New
I was working on an Ecto migration and I needed a timestamp. So, for the nth time, I looked up the different data types for timestamps, a...
New
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog
It says that Fly is going all-in on sprites, which is a worry ...
New
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using.
We’re particularly inte...
New
Is there a word for the ~> symbol used in Version strings?
Do you also just call it a Squiggle Arrow™ ?!
New
Other Trending Topics
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
ICal is a library for interacting with iCalendar data. It parses iCalendars into typed Elixir structs via ICal.from_ics, and can prepare ...
New
Latest Phoenix Threads
Latest on Elixir Forum
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #ai
- #phoenix_html
- #elixirconf-us
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 7- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
mpope
This is a personal style choice, but I prefer to keep business logic out of controllers and use pattern matching. I guess this depends on what patterns already are the norm in your app.
lud
Or you can pass the flags from the controller to the core as options. So the core stays functional but supports those options.
edit: well I misread @mpope post, because I am actually saying the same thing. So +1 for that.
JulienCorb
Thank you for sharing your view on this !
After some thought I’m leaning toward keeping any feature flag logic away from the core. Only functions to enable/disable/check flags would be in the core.
My main point being the following : if I have a web client and a mobile app client, if I put some flags logic in the core, it will make things more complicated if I want to use only flags in one of my clients.
Your solution with adding a
enabledboolean argument in my core function would be quite clean, but I could even get rid of it if I only maintain feature flags logic in controllers for example.The only drawback, if it is really one, is that it would make my controllers fatter. But is it really an issue?
l00ker
I know this a little off topic, but FWIW have a look at FunWithFlags. It may help you in other areas etc.
mpope
Since you’re pushing alot of your business logic into
coreand outside of your controllers, it sounds like you have a service layer (more or less). If this is the case, I think you could argue that you’re overloading your controller method. This is going to be an oversimplification from 1000 ft, but: If the mobile app and web client share the same business logic in the service layer and they require different flags why not have two separate routes and controller handlers?Ofcourse, if everything is live and running and the app is widely deployed, the choice might have already been made for you and you’ll need to get the flags in the controller based on whatever is in the session you’re using to differentiate mobile and web clients.
mpope
Now, if you’re juggling 30 flags…this might be bad advice
JulienCorb
That is indeed the case.
Both interfaces for web and mobile are mixed together, idealy I would have loved to push the split even further by having a
my_app_weband amy_app_mobilefolder.