An attribute domain is a computer programming concept that refers to the valid range of values permitted for a specific attribute in a program's code. Entering an incorrect value — a value outside of the permitted range — will often crash the program. The ideal method for ensuring that entered values do not stray outside of the valid range is to provide the end user with a display message indicating the range of acceptable values, reducing the risk that he or she will enter an inadvertently excessive value.
Variables are the crux of a program's code. When assigned, variables are given a specific type. An integer is a type of variable used when only whole numbers are permitted; a string, on the other hand, accepts any combination of letters, numbers or characters. Deciding upon the variable type places the initial constraints on the attribute domain of an item. For example, the end user cannot successfully enter "abcde" into an integer value. This preliminary restriction on the attribute domain is hard-wired into the programming language, so it cannot be changed, even by the individual coding the software.
In addition to the type of variable chosen, a programmer can place additional constrains on the attribute domain for a specific item. For example, if programming software for a hotel chain, the programmer might naturally limit the range of values for a "Hotel Room Number" attribute to the number of hotel rooms in the building. If the room numbers go from 100 to 1,000, it only makes sense to limit the attribute range of the variable correspondingly. This ensures that the program will not generate false results based on incorrectly entered data.
Once a programmer selects an attribute domain, he or she must program error-catching code to prevent users of the software from either inadvertently or maliciously attempting to crash the system by entering an out-of-range value. This is a simple routine which checks input values against given attribute ranges. If an attribute falls within the range, the program proceeds normally. If not, the program returns a simple "Incorrect Input" message and tries again, without permitting the variable to be filled until it is certain the input value is within the specific range allowed.