48
votes
Accepted
What is a good way to indicate that a number is not something you can count with?
You can use a wrapper class/struct around your string to communicate the intent of the value. It will also allow you to validate inputs and achieve compile time safety, depending on the language you ...
31
votes
What is a good way to indicate that a number is not something you can count with?
It sounds like you are already using string data types for these numbers (maybe in a data model or UML model or some code), but you want to prevent another dev to convert those strings accidentally to ...
10
votes
What is a good way to indicate that a number is not something you can count with?
What you're dealing with here is a non-technical problem, it's a human one.
There are technical solutions to be found here, but they don't cover the problem in its entirety. To repurpose an old saying,...
4
votes
What is a good way to indicate that a number is not something you can count with?
Use a string datatype, and maybe communicate permissible values in the documentation using regular expressions.
2
votes
What is a good way to indicate that a number is not something you can count with?
What you have are identifiers that just happen to be numeric. If you type them as identifiers, not numbers, then nobody is ever going to confuse the two.
There is of course no way to prevent ...
2
votes
What is a good way to indicate that a number is not something you can count with?
For example, create a class PhoneNumber and a class CreditCardNumber (careful about storing the latter), obviously without any method to turn it into a large integer. That prevents people from doing a ...
1
vote
What is a good way to indicate that a number is not something you can count with?
I use a lot of numbers which aren't "numbers". From account-numbers to patient-id numbers country codes to the codes for human sexes.
Strictly speaking, Users can't work directly with ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
programming-practices × 1575design × 152
java × 134
design-patterns × 120
object-oriented × 87
c# × 86
coding-style × 75
c++ × 71
patterns-and-practices × 68
architecture × 65
programming-languages × 65
python × 53
unit-testing × 47
javascript × 43
testing × 43
coding-standards × 42
php × 41
object-oriented-design × 38
development-process × 38
code-quality × 37
c × 36
project-management × 34
web-development × 33
version-control × 31
language-agnostic × 31