Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Assertions

Name: Anonymous 2011-08-16 8:54

I don't understand what's the point of assertions? Shouldn't unexpected cases be treated with proper error handling?

Name: Anonymous 2011-08-16 8:55

And unit tests, and contracts? Yes. They are the poor men's contracts.

Name: Anonymous 2011-08-16 9:06

Assertions are not for error detection, they're for stopping the program in case of data corruption and detecting nonsensical code when debugging.

Name: Anonymous 2011-08-16 9:39

Assertions are a development tool.

Name: Anonymous 2011-08-16 11:02

Assertions are poor-man's contracts

Name: Anonymous 2011-08-16 11:22

When interfacing with other systems, you often do not know the whole value range of data in advance, or even what to do with a certain data value. Assertions help during development in such cases, as you can easily leave an assertion in places you are uncertain of, and come back later after your program crashed to examine the unexpected values.

Name: Anonymous 2011-08-16 11:47

>>6
That's exactly what contracts are for, really. Assertions are a basic way to check contracts, except that contract violations (with some language support) can be detected at compile time (to certain extent), false assertions can't (not as easily).

Name: Anonymous 2011-08-16 11:55

The practice of assert()ing things come mostly from C. As I personally stated elsewhere (thread already dead), C is a brain-crippled language. Don't use it: they tend to persist and create bad habits. In C, you ought to preprocess with NDEBUG if you do use, but no one really compiles with that definition.

There are languages which create more interesting assertion mechanisms (throwing an exception for example). These are much saner and safe to use, maybe even in production code.

Name: Anonymous 2011-08-16 12:04

>>8
thread already dead
Yes, sure.

Name: !!kCq+A64Losi56ze 2011-08-16 12:26

In certain imperative programming languages, some weenie programmers will do some creative abuses with assertions, and like, use them to emulate certain boolean operations.

Name: Anonymous 2011-08-16 12:50

>>8
In C, you ought to preprocess with NDEBUG if you do use, but no one really compiles with that definition.
I don't think you know shit about C and its usage patterns, good sir.

Name: Anonymous 2011-08-16 12:58

>>11

I don't think you know shit about programming at all. Cheers.

Name: Anonymous 2011-08-16 16:52

>>11
I've been programming in C++ for about a year now. But I think I still haven't caught up to all its usage patterns. Where can you learn them?

Name: Anonymous 2011-08-16 17:03

>>12
Truth to be told, you're right. I only program a bit HTML now and then. I only come here to troll the fuck out of you guys. U mad? Deal w/ it!

Name: Anonymous 2011-08-16 19:29

>>8
Exceptions are not for asserting contracts. Your brain is crippled from too much object-oriented programming.

Name: Anonymous 2011-08-16 22:52

>>13
Look at the boost source code.

Name: Anonymous 2011-08-16 23:20

>>16
That would be like gazing directly into some non-euclidean anus!

Don't change these.
Name: Email:
Entire Thread Thread List