4 ms·
Init methods is the answer to that (but it potentially forces some additional complexity around initialized/not-initialized state into the other methods).
by reverius42 10y ago
Init methods is the answer to that (but it potentially forces some additional complexity around initialized/not-initialized state into the other methods).
- p4wnc6 10y agoIn fact, I think managing this extra state, also dealing with complications that could arise from object slicing, were the major reasons given when Martin Sústrik argued he should have originally started out with ZeroMQ in C and not in C++. < http://250bpm.com/blog:4 http://250bpm.com/blog:4 >
- deathanatos 10y agoAs I stated in my original post, these have the same classes of problems as null pointers: you have "constructed" an object whose internal state in invalid; a instance of Foo is either a Foo that init'd successfully or not-a-Foo (that failed to init/isn't initialized; a "zombie object") just as a pointer is either a pointer-to-something or a pointer-to-nothing. This is why you say "it potentially forces some additional complexity around initialized/not-initialized state into the other methods. At least in C++ (and many other OO languages), I find the downsides of having these Jekyll and Hyde classes outweigh any benefits that may come of ignoring exceptions.
- deleted 10y ago[deleted]