L
Lew
Arved said:To put it very succinctly, people expect constructors to return an
initialized object. And that's all a constructor should do. It will confuse
other people reading your code if you start non-initialization in a
constructor. In your above example a maintenance programmer would figure it
out, but it's not always that obvious.
It's got nothing to do with what "people expect". Doing work with an
incompletely-constructed object leads to bugs, that's why it's bad.
Software decisions are justifiable on an engineering basis, not on what people
expect or what will confuse them. It's a matter of the code doing what it is
supposed to instead of failing.