...and there’s even argument for suggestion that if the XML config file is missing from your project then Spring should assume that your application is annotation driven and attempt running - though I’m not too naive to assume that more thought would be needed here as this may have other ramifications.
But, I occasionally wonder whether it’s being taken too far with yet more and more convention rules to remember. As an example of this, consider the Model interface, you know the one: Spring passes a model object to your Controller’s handler method, you bung in some attributes and let the JSP get hold of them when your next view is being displayed. The Model has two methods for adding a simple attribute:
model.addAttribute("myBean", new MyBean());
In the above code snippet, both of these methods do exactly the same thing: they add an attribute to the model’s map with a “myBean” key. The first method uses explicit naming whilst the second figures out some name using the Conventions class:
String name = Conventions.getVariableName(new MyBean());
...which means that more code needs to run to add a simple value to a map. I’d also argue that the first, explicit, two argument addAttribute(...) is simpler to read and understand than the the second, single argument method. In the first case, you know the name of the attribute in the HTTP request , whereas in the second it’s assumed. However, the Guys at Spring haven’t fallen down on the job, the addAttribute(Object attributeValue) is fully documented with a link to the Conventions class and a mention that it uses the ‘JavaBeans property naming rules’ (which are buried for all to see on Page 57, Section 8.8 of the Sun JavaBeans Specification).
So, I guess the point is that we should think about the effects of adding Conventions to your code before you do it as we may be adding complexity. This leads back to a little psychology: programmers (including myself) like to look clever, we get kudos and cash for being clever, so I guess that we should remember that other important rule of programming: KISS.