Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 227157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:34:30+00:00 2026-05-11T19:34:30+00:00

I believe that most IoC containers allow you to wire dependencies with XML configuration

  • 0

I believe that most IoC containers allow you to wire dependencies with XML configuration file. What are cons and pros for using configuration file vs. registering dependencies in code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T19:34:30+00:00Added an answer on May 11, 2026 at 7:34 pm

    These pros and cons are based on my work with spring. It may be slightly different for other containers.

    XML

    pro

    • flexible
    • more powerful than annotations in some areas
    • very explicit modelling of the dependencies of your classes

    con

    • verbose
    • difficulties with refactoring
    • switching between several files

    Annotations

    pro

    • less file switching
    • auto configuration for simple wirings
    • less verbose than xml

    con

    • more deployment specific data in your code (usually you can override this with xml configs)
    • xml is almopst(?) always needed, at least to set up the annonation based config
    • annotation magic may lead to confusion when searching for the class that is used as dependency

    Code

    pro

    • Can take advantage of strongly-typed languages (e.g. C#, Java)
    • Some compile-time checking (can’t statically check dependencies, though)
    • Can take advantage of DSLs (e.g. Binsor, Fluent interfaces)
    • Less verbose than XML (e.g. you don’t need to always specify the whole assembly qualified name (when talking .net))

    con

    • wiring via code may lead to complex wirings
    • hard dependencies to IOC container in the codebase

    I am using a mix of XML+Annotation. Some things especially regarding database access are always configured via xml, while things like the controllers or services are mostly configured via annotations in the code.

    [EDIT: I have borrowed Mauschs code PROs]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I believe that quantifying the productivity increase (extra working hours) is the most effective
I believe that most of you have heard of preloading of images. But is
I believe that readability and the KISS principle are the most important things in
I am using IIS to develop some web applications. I used to believe that
I am a firm believer in the idea that one of the most important
I believe that Agile is nothing but another implementation of Spiral Model. I am
I believe that IDictionary classes works better with sortable objects. I believe also that
I believe that I have successfully impersonated my own user account while running an
I'm lead to believe that I cannot count on the order of items added
Premise I believe that there is a way to objectively define "Good" and "Bad"

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.