Wednesday, September 03, 2008

Status Class

Well, I made some progress on a project I'm working on. The I/O portion still needs work, but I did create something that is somewhat interesting: a status class. What I wanted to do was have the ability to record status information about any errors/failures/successes/etc. that occur when a member function is executed. I got the idea while reading some recent articles on exception and why they're bad, how they're misused, etc.

It's very simple. First, you have a set of states that represent the state of the recently executed function. Success, EOS (End of Stream), and Error are three of them. You can also set a message, which you need for an error. Now, there is a consistent way to check the status of a function and know what happened without relying on exceptions or special return codes.

Originally, this was supposed to be a helper class where it would encapsulate the result of the function as well as the status information. Now, I have it set up to be a base class that other classes can inherit from. Much cleaner and I think it'll work out quite nicely.

Now, back to getting my I/O module up to snuff.



Post a Comment

Links to this post:

Create a Link

<< Home