Category: 

What Is Bounds Checking?

Article Details
  • Written By: Mary McMahon
  • Edited By: Nancy Fann-Im
  • Last Modified Date: 28 October 2016
  • Copyright Protected:
    2003-2016
    Conjecture Corporation
  • Print this Article
Free Widgets for your Site/Blog
The mongoose was introduced to Hawaii in order to kill rats, but mongooses hunt in the day, while rats are nocturnal.  more...

December 7 ,  1941 :  Japanese bombers attack Pearl Harbor.  more...

Bounds checking is a procedure to make sure a variable conforms with the bounds of an array. In programming, variables that fall outside the bounds can create problems with the operation of a program and may freeze it or cause an error. For some types of programming languages, this procedure is standard to protect the integrity of operations and arrays, while in others it may need to be actively performed on an order from the operator.

In a simple example of bounds checking, if a programmer has an array ranging between two and 14 and tries to insert 16 as a variable, it does not fit. It would be out of bounds, and depending on what the array is used for, might create a serious error. For example, if the array represents available memory, an out of bounds variable would result in an illegal operation; the array doesn't allow it, and the system might create an error with the stored data or be unable to store it at all.

Ad

In bounds checking, it is possible to determine if a variable falls within an allowable range, or to evaluate an index to see if it fits within the stated bounds. If there is a problem, the program can flag it, allowing the programmer to fix it before attempting an operation that will fail. This can prevent the development of bad references and other issues that may arise when the bounds of an array are ignored. Computer errors related to violations of the bounds can be challenging to fix, and techniques to avoid them will make a program run more smoothly.

Handling of bounds checking in various programming languages varies. As people learn programming, they learn more about the full features and functions available and decide how best to use them, given the type of work they do. Numerous products can perform bounds checking if it is not native to a programming language. Some of these are available for free, and may not work with all systems or languages, but can provide a good start.

A failure to perform bounds checking can have consequences in the future, although the programmer may not notice the problem immediately. Debugging processes may include bounds checking to look for obvious issues. Multiple passes of debugging are typically part of the development process, to catch as many problems as possible before software is released to the general public. A poorly prepared product may be prone to error and could generate consumer frustration.

Ad

You might also Like

Recommended

Discuss this Article

Post your comments

Post Anonymously

Login

username
password
forgot password?

Register

username
password
confirm
email