Re: [morph-developer] InstantiatingReflector
Brought to you by:
orangeherbert,
sgarlatm
From: Matt S. <Mat...@wh...> - 2007-01-11 20:33:23
|
Matt Benson wrote: > IMO a basic implementation: > > look first for a single-arg constructor whose argument > matches "parameter". Failing that, if "parameter" is > an array, look for a multi-arg constructor whose > arguments all match the elements of "parameter". > After these approaches fail, I wouldn't do any more by > default, but simply fall back to newInstance(). I've > written code that does this stuff before, actually. > > The only thing about all this is it sounds pretty much > like a Converter implementation; the line between > Reflectors and Converters becomes blurry. :| > > -Matt Yeah, this is definitely not the recommended way to do this stuff. This would be a great place to quote one of Rod Johnson's books or the Spring manual, but I'm too lazy to find a good quote that goes over why you should just use default no-argument constructors. The support here is IMO for APIs over which the user has no control. If the user does have control over the API and they are using constructors with arguments, well, they deserve the mess that they have brought on themselves ;) Matt |