microsoft / alguidelines

Best Practices and Design Patterns for the AL Language
https://alguidelines.dev/
MIT License
129 stars 48 forks source link

No Magic Numbers use Named Constants #215

Closed SorenKlemmensen closed 1 year ago

SorenKlemmensen commented 1 year ago

Too often I see people that assign meaning to random numbers. We see this standard if people refer to objects by number or options by the integer value, however it happens to when importing file formats outside our control or people try to sort stuff with more. The rule should be "No Magic Numbers". Use meaning full abstractions that make the code readable instead. Magic Numbers obscured the intent for the reader.

Please discuss

SorenKlemmensen commented 1 year ago

I forgot to say that this has been touched on in https://alguidelines.dev/docs/bestpractices/named-invocations/ however I think it is a bigger issue better covered by "No Magic Numbers" in general.

SorenKlemmensen commented 1 year ago

I moved this to ideas where I should have created it in the first place... Beginner error :-)