3 ms·
Next step, please don't call your variables ..._percent but interpret 0.5 as meaning 50% of the reference value.
by dmurray 5y ago
Next step, please don't call your variables ..._percent but interpret 0.5 as meaning 50% of the reference value.
- Mazzen 5y agoHow do you mean?
- stilley2 5y agoNot GP, but 0.5% == 0.005, not 0.5.
- dmurray 5y agoSuppose our application deals with classifying cheese, and has a field for how much fat a given sample has, maybe it needs 20% to be classified as Grade A Ste-Madeleine-de-la-Foo. Some developers like to call this field MinimumFatContentPercent and set it to 0.2.
- BurningFrog 5y agoBad naming is a universe of programming flaws, much of which boils down to not thinking about how a different person might read your code the first time. Unfortunately "Theory of Mind" is weak in people on the spectrum.
- ______-_-______ 5y agoI 100% agree. That said, "percent" is a common and precise word, and I haven't come up with anything quite as good for variables in range [0,1]. I generally use "ratio," but I don't love the word. Is there anything better?
- FreeFull 5y agoMaybe "fraction" would be suitable.
- munch117 5y agoI use "andel", but if you don't write your variable names in Danish, then it might look a little strange. "Share" would be the direct translation, but that word usually means something else in programming. In English, I use "ratio" also; in context the meaning is always clear enough.
- ______-_-______ 5y agoThat's actually not a terrible idea! German is known for having words for concepts other languages lack, and I guess that applies to Danish by extension. Maybe I should ditch the thesaurus and teach myself German.
- WorldMaker 5y agoFrom one perspective it is the "normalized" unit, so not giving it a name makes as much sense as trying to find a word for it: if you were going to call something ProgressPercent the normalized float/double form is just Progress. This is probably the closest to what I try to stick too, but it can be hard especially if you have six other things that also want to be called "Progress" that aren't normalized floats/doubles. (Another name for the "normalized" unit is sometimes the "unit" unit. ProgressUnit sounds dumb, but is an available option in English and shorter than ProgressNormalized.)