Results 1 to 3 of 3

Thread: Auto-wiring best practice

  1. #1
    Join Date
    Jan 2006
    Location
    El Dorado
    Posts
    80

    Default Auto-wiring best practice

    Hi,
    For a large Spring based application, is it advisable to stick to "no" auto-wiring or byName/byType are ok and hold no issues?
    (From a best practice view point).
    Thanks.

  2. #2
    Join Date
    Apr 2008
    Location
    Philadelphia, US
    Posts
    198

    Arrow

    This is a philosophical question more than practical

    There are clearly two camps: "Autowire Everything" camp and "Don't Autowire Anything" camp. And I know very cool and clever people that belong to one or the other.

    My take on it: "It depends".

    I really like to use Autowire for Testing, it just makes sense, and makes testing so much easier.

    I however dislike to "Autowire" components on the "business side of things". But even that depends. If there are more than 5, 6 people on a team, I, in most cases, would not use Autowiring: very easy to misuse, confuse, etc... But if it is a small team with people that you can fully rely on, @Autowire will save you some time.

    On bigger projects 20+ people, there is almost no way you'll have 100% of people being solid developers: that is an "unfortunate truth". So removing unnecessary "magic" (Autowire) would be one way to reduce the confusion.

    There are exceptional cases, of course, where Autowire can be extremely useful no matter how big/small the project is. For example: injecting a low level property to an abstract class without having clients to worry about it.

    /Anatoly
    Humans are stateful and mutable beings that have no problems processing many things concurrently and share state with others + they are usually "coupled"

  3. #3

    Default

    For sanity's sake avoid autowiring. Create a separate application context file for testing.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •