"Assertive-Oppressive Computing" 6-9-04
Re: "Assertive-Oppressive Computing" 6-9-04
Missing on unreadable data. Google rox, eh?
[quote="WCH";p="349429"]What is an assertion error, anyway?[/quote]
When debugging a computer program, programmers will often make assertions in the code. An assertion is simply a statement that should always be true.
As an example, let's say we have an average function. It takes a list of integers as its input and computers the average. However, this only works if the list has items. What is the average of nothing? That's not defined.
So at the beginning of the function, there might be an assertion statement that asserts that the list has at least one item in it:
It is assumed that in all cases every call to the average function must contain at least one element.
(Technically, this example is a "precondition" assertion - a condition that must be met prior to the function being called. A "postcondition" is a condition that must be met after the function is called. For example, a function that computes an absolute value might have a postcondition asserting that the return value is greater than or equal to 0.)
If it does not, the "assert" call will flag an error. That is an assertion error - when an assertion is not met.
Generally speaking, after testing, these calls are removed from the program (or disabled), so you usually won't see assertion errors in commerical software. However, this is not always the case.
The best link I could find on assertions was unfortunately Programming With [Java] Assertions, which describes assertions in relation to the Java language and platform.
Assertions are an essential part of Design by Contract programming.
When debugging a computer program, programmers will often make assertions in the code. An assertion is simply a statement that should always be true.
As an example, let's say we have an average function. It takes a list of integers as its input and computers the average. However, this only works if the list has items. What is the average of nothing? That's not defined.
So at the beginning of the function, there might be an assertion statement that asserts that the list has at least one item in it:
Code: Select all
function average(integerList) {
assert(integerList.length > 0);
// computer the average
}(Technically, this example is a "precondition" assertion - a condition that must be met prior to the function being called. A "postcondition" is a condition that must be met after the function is called. For example, a function that computes an absolute value might have a postcondition asserting that the return value is greater than or equal to 0.)
If it does not, the "assert" call will flag an error. That is an assertion error - when an assertion is not met.
Generally speaking, after testing, these calls are removed from the program (or disabled), so you usually won't see assertion errors in commerical software. However, this is not always the case.
The best link I could find on assertions was unfortunately Programming With [Java] Assertions, which describes assertions in relation to the Java language and platform.
Assertions are an essential part of Design by Contract programming.
-
BillyBlaze
- Redshirt
- Posts: 2512
- Joined: Thu Oct 09, 2003 4:34 pm
-
Lord Terrible
- Redshirt
- Posts: 129
- Joined: Fri Mar 19, 2004 2:58 pm
In other words, it's the programmer giving you the finger because some other programmer didn't do his homework.
[quote="dmpotter";p="349475"][quote="WCH";p="349429"]What is an assertion error, anyway?[/quote]
When debugging a computer program, programmers will often make assertions in the code. An assertion is simply a statement that should always be true.
etc.....
[/quote]
[quote="dmpotter";p="349475"][quote="WCH";p="349429"]What is an assertion error, anyway?[/quote]
When debugging a computer program, programmers will often make assertions in the code. An assertion is simply a statement that should always be true.
etc.....
[/quote]
Who is online
Users browsing this forum: No registered users and 1 guest
