Wednesday, November 7, 2007

Twelve Best Practices For Spring XML Configurations

Twelve Best Practices For Spring XML Configurations

In this article, I will show you 12 best practices for Spring XML
configurations. Some of them are more necessary practices than best practices.
Note that other factors, such as domain model design, can impact the XML
configuration, but this article focuses on the XML configuration's readability
and manageability.

1. Avoid using autowiring

2. Use naming conventions

3. Use shortcut forms

4. Prefer type over index for constructor argument matching

5. Reuse bean definitions, if possible

6. Prefer assembling bean definitions through ApplicationContext over imports

7. Use ids as bean identifiers

8. Use dependency-check at the development phase

9. Add a header comment to each configuration file

10. Communicate with team members for changes

11. Prefer setter injection over constructor injection

12. Do not abuse dependency injection