Re: Is creating anonymous objects bad practice?
- From: "Arved Sandstrom" <asandstrom@xxxxxxxxxxxxx>
- Date: Sat, 29 Nov 2008 15:34:27 GMT
"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
.
- References:
- Is creating anonymous objects bad practice?
- From: Peter D.
- Re: Is creating anonymous objects bad practice?
- From: Arved Sandstrom
- Re: Is creating anonymous objects bad practice?
- From: Lew
- Is creating anonymous objects bad practice?
- Prev by Date: Re: Is creating anonymous objects bad practice?
- Next by Date: Re: Quirk with generics
- Previous by thread: Re: Is creating anonymous objects bad practice?
- Next by thread: Re: Is creating anonymous objects bad practice?
- Index(es):
Relevant Pages
|