Best Practices with Spring Framework

Posted: November 17, 2011 in Java, Spring
Tags: , , , , ,
    1. Prefer ApplicationContext over Bean Factory
    2. Try avoiding declaring PROTOTYPE beans. By default all beans defined in spring are singleton.
    3. Use Inner beans when you don’t want a bean to exist without its parent. (example :target for AOP proxy)
    4. Avoid using Autowiring as autowiring byType or byConstructor might result in ambuiguity exception while autowiring byName is more dangerous as bean names might be changed over time, leaving several beans unwired or wired to wrong beans.
    5. Using clear, descriptive, and consistent name conventions across the project is very helpful for developers to understand the XML configurations.
    6. Use ‘id’ as the bean identifier even though you have an option to use ‘name’ as bean identifier
    7. Prefer ‘type’ over ‘indexing’ during constructor-based dependency injection
    8. Use </null> to set any property to null value
    9. Separate deployment details from application context
    10. Try to use Spring AOP over AspectJ
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s