News for hackers. Stuff that matters.
Re:Please put units in names by dmurray on Monday March 21, 2022 @05:28AM (#30752003)
Next step, please don't call your variables ..._percent but interpret 0.5 as meaning 50% of the reference value.
Re:Please put units in names by ______-_-______ on Monday March 21, 2022 @10:14AM (#30754380)
I 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?

Re:Please put units in names by WorldMaker on Monday March 21, 2022 @06:11PM (#30760378)
From 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.)

Re:Please put units in names by munch117 on Monday March 21, 2022 @02:35PM (#30757938)
I 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.
Re:Please put units in names by ______-_-______ on Monday March 21, 2022 @03:25PM (#30758569)
That'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.
Re:Please put units in names by FreeFull on Monday March 21, 2022 @12:25PM (#30755997)
Maybe "fraction" would be suitable.
Re:Please put units in names by BurningFrog on Monday March 21, 2022 @08:10AM (#30753119)
Bad 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.

Re:Please put units in names by Mazzen on Monday March 21, 2022 @06:41AM (#30752428)
How do you mean?
Re:Please put units in names by dmurray on Monday March 21, 2022 @07:51AM (#30752975)
Suppose 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.
Re:Please put units in names by stilley2 on Monday March 21, 2022 @07:10AM (#30752613)
Not GP, but 0.5% == 0.005, not 0.5.