Stripes - Convention over Configuration
December 3rd, 2007I’ve sat on the fence for a number of years on the topic of using XML for configuration. Being familiar with XML helped me to overcome the nagging feeling that it just doesn’t seem ideal. Well, I’m no longer on the fence and I can thank Stripes for it.Stripes is a web application framework for Java, it falls in the same category as Struts. Stripes takes the “Convention over Configuration” approach and this really separates Stripes from the pack. Utilizing Annotations instead of XML, streamlined configuration requirements, and (my favorite) event binding, I am able to get projects started quickly and easily. Seasoned developers of other frameworks will tell me they are able to do the same, and of course they can, they’re seasoned experts. But, the simple configuration requirements in Stripes leaves little room for snags and bugs found when configurations don’t match up (struts-config.xml anyone?). Developers shouldn’t have to battle with configuration, especially when so many applications all start the same way. This is where Annotations over XML comes in.
Because I can annotate my action bean in Stripes I can localize configuration errors to the responsibility or set of responsibilities I’m developing (Yay event binding !). Now my configuration is clearly and cleanly attached to my code, making it easy to find, easy to adjust, and easy to debug. The days of massive XML files containing all process flow for your application in a single file are over!
Event Binding is something I really enjoy about Stripes. Event Binding allows me to put multiple responsibilities into my Action bean, reducing the number of files required for the application. Using Annotations I can create a single Action bean designed to handle all responsibilities for a common subsystem, such as user management. In other frameworks I may have created Action beans such as: AddUser, UpdateUser, ShowUserForm, etc. With Stripes I can create a single action bean called Users and put all the functionality in it, bound to callable events using Annotations. This, to me, is a prime case of convention over configuration. It’s more simple and less complex. There is cleverness in simplicity.
Although I’ve compared to Struts this isn’t a “Stripes is better than Struts” article. Preference, requirements, obligations, and suitability all factor into a decision for Java frameworks. If you’re seeking some functional examples of how Annotations can be used in place of typical XML configurations I highly recommend you try Stripes. Hibernate is another fine example as well, but that’s another post in another category.
http://mc4j.org/confluence/display/stripes/Home
http://www.hibernate.org/