Hi all-
I've never seen this particular issue addressed, but was wondering if
there's anything to support one way or another. Say I have a class:
class ManipulateData
{
public:
ManipulateData(const char* Path-To-Some-Text-File)
{ ... }
bool Run();
long DataCount();
... etc ...
};
What I'm wondering is if the Run() function is really necessary. If a class
so completely encapsulates a particular type of functionality that under C
it probably would have been written as a single function, with no further
setting of members, is it really necessary or proper to split the start into
both the constructor *and* the Run()? True the Run() returns a bool that
would presumably indicate success, but my thought is that because the bool
only indicates sucess or failure, and in the case failure might be for
multiple reasons, it would be better to put the object in a try/catch and if
the object cannot do what it's supposed to do, throw an exception and caught
by the function that instantiated the object.
I ask because I realize I've written code that says "ManipulateData
md("/tmp/blah.txt"); bool bOK(md.Run());" and it seems ... unnecessary.
Just curious what others thought,
Jenna