A programming concept.

When accessing an array in memory, it's a common error to access a part of an array that doesn't exist. For instance, trying to access element 9 in an array that is only 7 elements long. Bounds checking covers this, but is a bit more of a generic concept as well.

In general, bounds checking as a concept is a way of making sure that a program never tries to access something that doesn't exist. In object-oriented systems, any container class can provide bounds checking with get/set functions. For instance, a Vector class can provide a function named Access() that checks the element the program is trying to access is valid.

Bounds checking in object-oriented systems is easy because of encapsulation - any complex container class should be aware of its current size. In languages with no support for encapsulation (BASIC springs to mind) it's a little less neat - you need to keep the bounds of the array recorded in other variables in the same scope as the array.

Bounds checking is yet further support for get/set functions in OO systems, and should be included in any abstract system so that users can't break it.

Log in or register to write something here or to contact authors.