Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualsamoth

Posted 01 August 2013 - 12:35 PM

That's an example of expection handling (no, that's not a typo).

 

While this certainly "works", most people will consider it an abuse of the language. Also, it will certainly not reduce branch complexity, on the contrary. It will have the same branch complexity (only you don't see it!) plus RTTI overhead plus stack unwinding overhead.

 

Personally, I would prefer bar.getStringValue() to return a default string if it can't provide anything better. This also has no branches (only hidden inside the class, but not visible to the user), and it feels "cleaner". But of course that's a bit of a matter of taste, too.


#1samoth

Posted 01 August 2013 - 12:29 PM

That's an example of expection handling (no, that's not a typo).

 

While this certainly "works", most people will consider it an abuse of the language. Also, it will certainly not reduce branch complexity, on the contrary. It will have the same branch complexity (only you don't see it!) plus RTTI overhead plus stack unwinding overhead.

 

Personally, I would prefer bar.getStringValue() to return a default string if it can't provide anything better. This also has no branches (only hidden inside the class, but not visible to the user), and it feels "cleaner". But of course that's a bit of a matter of taste, too.


PARTNERS