Re: assert vs. std::logic_error?
On Nov 24, 2:50 pm, rpbg...@yahoo.com (Roland Pibinger) wrote:
On Fri, 23 Nov 2007 09:31:14 +0100, "Alf P. Steinbach" wrote:
* Roland Pibinger:
asserts and tests are not related. Production code which is tested
contains no assets.
That's a good way to transform easily identifiable bugs into more
nebulous general "instability".
Any real-world example for programs that ships with asserts?
All of the routing software at Deutsche Telekom (and that's one
big network); Deutsche Telekom (and its spin-offs, like T Mobil)
require it. All of the network management programs from
Alcatel.
All of our trading software in the bank where I currently work.
(Funny thing about bankers: they prefer a crash to issuing a buy
order when they meant sell.)
Another argument against asserts in production code is
performance: asserts significantly slow down the program (if
they don't you haven't used enough asserts in your code).
That depends a lot on the program. All of the programs I've
worked on in the last 20 or so years have been I/O bound. And
asserts certainly don't slow up disk accesses.
BTW, asserts seem to be a C and C++ only thing. For my work I
mostly use Java and I have neither used nor missed asserts.
They are not necessary in that environment.
That's because Java can't be used in critical systems, when
reliability is important.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34