[FEATURE]: avoid double negation by introducing `enabled:` for modules
See original GitHub issueFeature Request
Deprecate disabled:
module option and introduce enabled
.
Alternatively, encourage using enabled
and still allow disabled
in the cases where it makes the code more readable.
Background / Motivation
Starting out positive, both the positive and the negative case are easy to understand:
enabled: ${environment.name != "local"}
(read: enabled if environment is not local)enabled: ${environment.name == "local"}
(read: enabled if environment is local)
While starting out negative, the negative case can be harder to read:
disabled: ${environment.name != "local"}
(read: disabled if environment is not local)
Examples with simple boolean algebra:
Easy to understand:
enabled: ${environment.name == "kubernetes" || environment.name == "local-kubernetes"}
(read: the module is enabled if the environment is kubernetes or local-kubernetes)enabled: ${environment.name != "kubernetes" && environment.name != "local-kubernetes"}
(read: the module is enabled if the environment is not kubernetes and not local-kubernetes)disabled: ${environment.name == "kubernetes" || environment.name == "local-kubernetes"}
(read: the module is disabled, if environment is kubernetes or local-kubernetes)
Hard to understand
disabled: ${environment.name != "kubernetes" && environment.name != "local-kubernetes"}
(read: the module is disabled, if environment is not kubernetes and is not local-kubernetes)
So, to sum it up, enabled is okay to understand in all cases, and disabled is hard to understand in case of double negation (at least for me, but also to other people).
What should the user be able to do?
use enabled:
to configure wether a module is active, instead of disabled
.
Why do they want to do this? What problem does it solve?
Readability
Suggested Implementation(s)
There are 2 options:
- We can have both
enabled
anddisabled
side by side - We can deprecate
disabled
How important is this feature for you/your team?
🌹 It’s a nice to have, but nice things are nice 🙂
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:8 (2 by maintainers)
Top Results From Across the Web
[FEATURE]: avoid double negation by introducing `enabled:` for ...
use enabled: to configure wether a module is active, instead of disabled . Why do they want to do this? What problem does...
Read more >Avoid double negation, unless... - Adam Sawicki
If something has always been enabled in previous versions and you want to give users a possibility to disable it in the new...
Read more >All C++20 core language features with examples
All C++20 core language features with examples · Introduction · Table of contents · Concepts · Modules · Coroutines · Three-way comparison ·...
Read more >openresty/lua-nginx-module: Embed the Power of ... - GitHub
NGX_LUA_USE_ASSERT When defined, will enable assertions in the ngx_lua C code base. Recommended for debugging or testing builds. It can introduce some (small) ......
Read more >2. Building and Running Modules - Linux Device Drivers, 3rd ...
This chapter introduces all the essential concepts about modules and kernel ... resources or avoids clean up altogether, the exit function of a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think most of this would be solved by just naming the complicated expression with a variable
I’m okay with keeping both, good point!
@vvagaytsev @Orzelius I would just create a pull request towards 0.13 once all the tests pass? What do you think?