DRY: brief guide to keep you dry

Some years ago a Bachelor teacher told us there's enough with a few principles to explain most nature phenomena. Osmosis, conservation of energy and a few others can model most of the things we see.

I think it happens the same with computing. In spite of the huge amount of languages, libraries and platforms there are, the grounds which make them good tools are very similar. Maybe the most important among them is "DRY principle": Don't Repeat Yourself. Repeating implies more work (a good programmer should be lazy), duplicating errors, reducing code mantainability, making changes harder... Here it comes the great sentence: "Every time you copy-paste, Lord kills a kitten".

My work environment for the last years has been J2EE, and I use the following tools to keep me dry:

Hibernate: minimizes data access code.
Hibernate Validator: takes advantage of persistence specification to check form data correctness and shows user error messages. If you don't use Hibernate you should have a try on Commons Validator.

Templating and cutting up pages, whether Tiles (a must if you still use Struts) o Facelets (best reusing with JSF).

Intensive CSS for presentation. There's no good at "improving presentation with CSS". The best thing you can do is composing web pages structure with XHTML independently from presentation, delegating 99% to CSS (1% left is for IE hacking).