Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Standard naming to the Spring beans

Somebody knows an standard naming to the Spring beans in a App Context?

I used the camel case naming, but I'm not sure if exists an kind of standard, I searched in the net about that but I haven't found something.

like image 403
thegeekinside Avatar asked Mar 15 '11 16:03

thegeekinside


2 Answers

Bean Naming Conventions (Spring Framework Reference section 1.3.1)

The convention is to use the standard Java convention for instance field names when naming beans. That is, bean names start with a lowercase letter, and are camel-cased from then on. Examples of such names would be (without quotes) 'accountManager', 'accountService', 'userDao', 'loginController', and so forth.

Naming beans consistently makes your configuration easier to read and understand, and if you are using Spring AOP it helps a lot when applying advice to a set of beans related by name.

like image 177
skaffman Avatar answered Oct 23 '22 08:10

skaffman


camelCase seems right! For bean Id's, the naming convention would be same as Java class field name. The bean ID for an instance of ServiceDAO would be serviceDAO. The package name can be prefixed to the bean ID for larger projects.

like image 30
Piyush Mattoo Avatar answered Oct 23 '22 10:10

Piyush Mattoo