September 2016
Intermediate to advanced
270 pages
5h 16m
English
Note how in the preceding example I always put my constant numeric variables in class constants, as opposed to directly putting them in the code itself:
const minRate = 2.50; const secondsInDay = 60 * 60 * 24; const mileRate = 0.2;
The reason I did this was to avoid an anti-pattern known as magic numbers or unnamed numerical constants. Using class constants makes code easier to read, understand, and maintain; and of course, under the PSR standards, they should be declared in uppercase, separated by underscores.
Read now
Unlock full access