E
Erik Wikström
I just thought of a question that I have never seen discussed before
(perhaps it is trivial?) and while I think I know the answer I realise
that others might have other oppinions, which is why I ask it here.
How much code should one put in the try-block, i.e. if you have code
such as this:
foo;
bar;
baz;
try {
somecode;
}
catch (exception& e) {
// ...
}
and you have to posibility to also put foo, bar, and baz in the try-
block, should you do so?
I think no, since by limiting the stuff in the try-block I more
clearly indicate what might throw (or which depends on something not
throwing) than I do if I put as much as possible in it. Are there any
other oppinions or motivations?
(perhaps it is trivial?) and while I think I know the answer I realise
that others might have other oppinions, which is why I ask it here.
How much code should one put in the try-block, i.e. if you have code
such as this:
foo;
bar;
baz;
try {
somecode;
}
catch (exception& e) {
// ...
}
and you have to posibility to also put foo, bar, and baz in the try-
block, should you do so?
I think no, since by limiting the stuff in the try-block I more
clearly indicate what might throw (or which depends on something not
throwing) than I do if I put as much as possible in it. Are there any
other oppinions or motivations?