Skip to main content
added 9 characters in body
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

iI think 100 IS a magic number here.

Percentage is vastly used, but also per mille (1/1000) is often used, and basis point (1/10.000) and percentmillepercent mille (1/100.000) are used enoughtenough to have their own name.

I would change youyour function to getPerPart(value, part) and and getFromPart(value, part), maybe with a default getPerPart(value) and and getFromPart(value) witch, which use DEFAULT_PART_VALUE = 100.

alsoAlso, you may still want to write a getPercent, in thatwhich case the use of hardcoded 100 is fine.

i think 100 IS a magic number here.

Percentage is vastly used, but also per mille (1/1000) is often used, and basis point (1/10.000) and percentmille (1/100.000) are used enought to have their own name.

I would change you function to getPerPart(value, part) and getFromPart(value, part), maybe with a default getPerPart(value) and getFromPart(value) witch use DEFAULT_PART_VALUE = 100

also you may still want to write a getPercent, in that case the use of hardcoded 100 is fine

I think 100 IS a magic number here.

Percentage is vastly used, but also per mille (1/1000) is often used, and basis point (1/10.000) and percent mille (1/100.000) are used enough to have their own name.

I would change your function to getPerPart(value, part) and getFromPart(value, part), maybe with a default getPerPart(value) and getFromPart(value), which use DEFAULT_PART_VALUE = 100.

Also, you may still want to write a getPercent, in which case the use of hardcoded 100 is fine.

Source Link
Lesto
  • 141
  • 4

i think 100 IS a magic number here.

Percentage is vastly used, but also per mille (1/1000) is often used, and basis point (1/10.000) and percentmille (1/100.000) are used enought to have their own name.

I would change you function to getPerPart(value, part) and getFromPart(value, part), maybe with a default getPerPart(value) and getFromPart(value) witch use DEFAULT_PART_VALUE = 100

also you may still want to write a getPercent, in that case the use of hardcoded 100 is fine