Don’t Forget To Describe Your constructor-arg

January 20, 2006 – 22:47 | java, spring

One often overlooked feature in Spring bean definitions is the ability to add a <description> element to almost everything: beans, properties, or constructor arguments. It makes a lot of sense especially in the case of <constructor-arg>, because usually setting a bean property is fairly obvious:

XML:
  1. <property name="timeInterval" value="100"/>

But not so when the above is done in a <constructor-arg>. Constructor arguments are not looked up by name, but by index or type:

XML:
  1. <constructor -arg index="0" value="100"/>

Instead, this would make it a lot clearer:

XML:
  1. <constructor -arg index="0" value="100">
  2.   <description>For the time interval. In milliseconds.</description>
  3. </constructor>

My only wish is for the Spring team to consider adding a 'description' attribute.

Trackback from your site, or follow the comments in RSS.

Post a Comment