Re: Is creating anonymous objects bad practice?



"Lew" <noone@xxxxxxxxxxxxx> wrote in message
news:ggqeh7$12d$1@xxxxxxxxxxxxxxxxxxxx
Arved Sandstrom wrote:
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.
--
Lew

Ok, maybe it's just me. Because when I look at code - mine or that of
others - I sure do *expect* certain things to behave a certain way.
Including constructors. The _reason_ I expect that is because of software
engineering best practices or local conventions.

AHS


.



Relevant Pages