Skip to main content
GameDev.net gamedev.net
🔒 Locked

How many try blocks

Started by wood_brian Nov 9, 2011 at 3:17 AM 6 replies 1.9k views
Original Post
wood_brian
wood_brian
How many try blocks do you have in your program/project and what is the size of your program/project?
Telastyn
Telastyn

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.
Ezbez
Ezbez
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).
Hodgman
Hodgman
* 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?
21st Century Moose
21st Century Moose
As many as the program needs.
Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls. 
L. Spiro
L. Spiro
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
I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid
Postie
Postie
About 4 or 5, but that's due to interaction with external API's that throw exceptions for non fatal error conditions.
[size="2"]Currently working on an open world survival RPG - For info check out my Development blog:[size="2"] ByteWrangler
Sepiantum
Sepiantum
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.
Follow and support my game engine (still in very basic development)? Link

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.