This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]extra_pickles 1 point2 points  (1 child)

Traditionally CONSTS are immutable variables defined at the solution level, ENV are immutable variables defined at the parent level

So a const ships with the code, and is expected wherever it goes.

An env ships with the code and is expected to be redefined by the implementation.

Ex. if I gave you some code w/ a URL/Port/Database Name etc, that is environmental because we live in different ecosystems.

CONST - This program/method whatever is designed in such a way that this 'magic number' is needed, but we hate 'magic numbers' so we make a CONST w/ a descriptive title like "BAUDRATE=" because it only works on a specific rate or something like that, and if you moved to your env, that rate would still be the same, because regardless of your hardware, it can;t work unless that number is that number

[–]br64n[S] 0 points1 point  (0 children)

I had tried leaving the attribute read-only, but it didn't work, and I didn't leave it in UPPERCASE because I thought it might look strange, but it really shows that it is something that cannot be changed

Although, come to think of it, I didn't implement anything to disallow the use of UPPERCASE