Announcement Announcement Module
Collapse
No announcement yet.
Auto-wiring best practice Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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

    Comment


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

      Comment

      Working...
      X