On Wed, 29 May 2019 at 12:35, G. P. B. <george.bany...@gmail.com> wrote:
>
> Also I think those kind of magic numbers should be constants with
> meaningful names, and it that case you could just compute them by adding
> powers of ten.
> E.g. DISCOUNT_IN_CENTS = 1 * 10^5 + 3 * 10^4 + 5 * 10^3;

I agree naming things is important, but when I'm working with
non-programmers (e.g. the people in the accounts department), and we
have lots of numbers in front of us, something like:

EXAMPLE_ON_BUDGET                 = 1_000_000;
EXAMPLE_UNDER_BUDGET         = 990_000;
EXAMPLE_OVER_TARGET            = 1_001_000;
EXAMPLE_WAY_OVER_BUDGET  = 1_100_000;

is going to be way easier to read than either the version without
underscore, and definitely easier than power of ten notation.

cheers
Dan
Ack

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to