From: Matt B. <gud...@ya...> - 2007-01-11 20:50:28
|
--- Matt Sgarlata <Mat...@wh...> wrote: > 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 > Hard to say about your invocation of Rod. I just read the pro-con listing for property vs. constructor injection in "Expert One-on-One J2EE Development without EJB" and it agrees with what you've said, but I think interface21's views could be evolving on the subject... Ben is one of them, after all, and he's the requestor here. I know that Keith Donald was pushing for more constructors and fewer setters in Spring Web Flow, and I think the constructor parameter name discovery thing Ben mentioned might have originated with some of the AOP stuff, possibly brought in by Adrian Colyer (but that's complete guesswork on my part). Anyway, I only went into all that to play devil's advocate, as I will tend to do. I am in actuality undecided as yet what the best solution is here. Ben, can you provide a little more info on your setup? -Matt B > > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get > the chance to share your > opinions on IT & business topics through brief > surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > morph-developer mailing list > mor...@li... > https://lists.sourceforge.net/lists/listinfo/morph-developer > ____________________________________________________________________________________ Have a burning question? Go to www.Answers.yahoo.com and get answers from real people who know. |