Jump to content
  • Advertisement
Sign in to follow this  
wood_brian

How many try blocks

This topic is 2594 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement

How many try blocks do you have in your program/project and what is the size of your program/project?


1.
5017 lines.

Though I must say this is rather a-typical, even for a project that's still in the prototyping phase.

Share this post


Link to post
Share on other sites
I'm not sure how much this data means. Everything depends upon language and programming style. In Python, for example, use of try blocks is encouraged where as in C++ it must be done with much more caution.

The project I am working on probably uses about 5 try blocks per thousand lines of Python code. I can't think of any uses in our C++ code, but there might be some and some of our code is written more in the style of C than C++ (I am less familiar with that part of our project).

Share this post


Link to post
Share on other sites
* Zero try blocks in millions of lines of C++ code.
* One __try block in the C++ unit-testing code.
* Probably dozens/hundreds of try blocks in the C# project...


What is this supposed to mean anyway? What are you hoping to discover from this straw poll?

Share this post


Link to post
Share on other sites
I get it. This is one of those hidden camera shows.

My current C++ engine has 1 where the Flex/Bison parser is required to interact with std templates that throw exceptions on failure.
I don’t think you will get anything out of this poll.
For your own code, use them or don’t. In games, people tend not to, but it is still an option.
But you still must use them when working with outside libraries that throw exceptions.


L. Spiro

Share this post


Link to post
Share on other sites
About 4 or 5, but that's due to interaction with external API's that throw exceptions for non fatal error conditions.

Share this post


Link to post
Share on other sites
0 try blocks, 9000+ lines of code. The point is to always use a return type for functions that may fail and CHECK TO SEE IF IT FAILS. Then your code can handle it any way it wants to.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!