2 ms·
I have changed file permissions using chmod, I understand how you can with a single value represent state of different flags/settings, by assigning 1, 2, 4, 8..
by mewpmewp2 5y ago
I have changed file permissions using chmod, I understand how you can with a single value represent state of different flags/settings, by assigning 1, 2, 4, 8... for each flag, however I wouldn't have thought of it if someone asked me about setting a bit. It's not rocket science, I'm just not aware what the term means, nor have I ever consciously programmed something to "set a bit". I don't remember using syntax like flag = flag | thebit. And if I were to change file permissions programatically, it's very likely something like this would and should be abstracted away.
And for enums/config in general I have used something on a higher level, like json/key values config or when I code programmatically, having actual string values for the enums. It seems in most cases representing a config with a single value is overkill and would only decrease code readability. And for readability/maintainability purposes it doesn't make sense to me to have arbitrary numeric values representing setting values, unless we truly have storage issues, but for web apps readability trumps at least here.
Maybe I'm even now still misunderstanding why setting a bit is important.