February 08, 2006

Useful Spring tips

Writing about web page http://www.onjava.com/pub/a/onjava/2006/01/25/spring-xml-configuration-best-practices.html?page=1

Nothing too outstanding here, and I am not sure I agree with all of the tips, but a useful page for newbies :)

In particular, I disagree with not using autowiring; autowiring by type is safer than byName, and is very useful. Maybe I am making this point too strongly; I think it is fine to either use it or not.

The point I most strongly disagree with is preferring setter injection over constructor injection. That is just plain wrong ;) Constructors for collaborators which the class requires to work, setters for optional parameters. Simple as that.

But all in all, a nice quick read.


- 2 comments by 2 or more people Not publicly viewable

  1. Chris May

    I didn't know you could do type-based constructor injection. That makes things a lot nicer than index-based, which is always a massive PIA when you add or remove constructor parameters. It also encourages passing in complex types for collaborators instead of just Strings and ints.

    The advice to use setter injection over constructor is just bizzare…

    08 Feb 2006, 20:34

  2. Type based constructor autowiring is (IIRC) a relatively new thing, maybe a couple of point releases ago; not sure.

    The problem is that a lot of core Spring classes don't use constructor args (because constructor args weren't in 0.1) and it just got worse from there :(

    08 Feb 2006, 20:46


Add a comment

You are not allowed to comment on this entry as it has restricted commenting permissions.

February 2006

Mo Tu We Th Fr Sa Su
Jan |  Today  | Mar
      1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28               

Search this blog

Tags

Galleries

Most recent comments

  • Interesting… While I'm not completely convinced in such microbenchmarks, I'm pretty sure that 1ms … by Alexander Snaps on this entry
  • Hello. I bought the book yesterday. I was trying to find the source code for chapter 11 and chapter … by Suleman on this entry
  • http://woosight.net/account/login?username=demo by live mashup demo on this entry
  • Thanks mate ….. This blog was really helpful. by Maaz Hurzuk on this entry
  • Ty. Not directly helpful for my problem, but pointed me in the right direction. You will also get th… by Mike E. on this entry

Blog archive

Loading…
Not signed in
Sign in

Powered by BlogBuilder
© MMXX