I would go with text. It's OK to have a string where you only use numbers. As a rule of thumb: you should not use integers for things that are not mathematical in nature. That is, if you can do addition or multiplication on the values in a sensible way, then it's a number. Otherwise it's an identifier and you should stick with text. In practice you will ...
I cannot figure out a good way to explain why words should be in a
specific order, except for "It how it's written in English"
That's because it is the only reason for writing it this way.
There is a naive view that there is a consensus that all programming should be done in american English. But this isn't really the case, let the developers choose ...
"File Path" is a noun phrase. You want to find a way to explain the syntax of noun phrases in english, in particular where the head noun appears (at the end in this and similar phrases), and that the the value returned should be an instance of the thing named by the head noun.
Your function presumably returns a path, in particular the path of a file. If you ...
Not exposing things is fundamentally preferable because it avoids commitment to an implementation.
Once you've added something to a public interface, you cannot easily remove it ever again without possibly breaking clients. Someone, somewhere might be using it and complain if you later have to rename or remove it.
You should view publishing things as a ...
Do you need to do math on it? if errorCode>9000 etc
Do you need to pass it into anything that expects an integer?
Do you want an early error if you accidentally type an x in the code value?
If you answered no to all of these I can't see a reason why not to use strings.
As for your comment about 0012 vs 12, that's a presentation issue. The backend shouldn'...
Basically it boils down to "How much does your software cost to run?"
Every extra bit of work your code does costs money in terms of CPU, Memory, Disk Space, Bandwidth, electricity, rack space etc etc.
If its low volume, the extra cost will be tiny. But once you scale up you will be spending thousands of pounds every month. If you can knock 10% off the ...
I'd suggest to a static constant string to both be able to map to i18n and keep expressiveness.
Something like this is nice:
And you can even scope it to module to locate the origin of the error and avoid overlapping:
Or, you could also add the http response code inside the object, but that's ...
Nobody has brought this up but numbers are usually better for i18n. The client can decide what text to display. In many cases the client will have to translate the text depending on the locale, so in most cases this is easily done on the client as there are mechanisms to handle internationalization.
@Bellon's answer also sends the text as well for ...