Re: Is creating anonymous objects bad practice?
- From: Lew <noone@xxxxxxxxxxxxx>
- Date: Fri, 28 Nov 2008 22:56:22 -0500
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
.
- Follow-Ups:
- Re: Is creating anonymous objects bad practice?
- From: Tom Anderson
- Re: Is creating anonymous objects bad practice?
- From: Arved Sandstrom
- Re: Is creating anonymous objects bad practice?
- References:
- Is creating anonymous objects bad practice?
- From: Peter D.
- Re: Is creating anonymous objects bad practice?
- From: Arved Sandstrom
- Is creating anonymous objects bad practice?
- Prev by Date: Re: Is creating anonymous objects bad practice?
- Next by Date: Re: Simple integer factorization algorithm
- Previous by thread: Re: Is creating anonymous objects bad practice?
- Next by thread: Re: Is creating anonymous objects bad practice?
- Index(es):
Relevant Pages
|