Thursday, May 19, 2011

freemarker

Two things.

1) Find a concern across many problems that you can standardize with sufficient metadata to drive an algorithm.
2) Use freemarker to standardize the code generation and save yourself a lot of time.

I recently did this by extending the hibernate-tools suite and the hibernate3-maven-plugin to give my organization what it needs -- well, part of what it needs -- a data access layer code generator that takes it to the next level. Generics, AOP and pseudo-partial classes. This solidifies the pattern and practice and is extremely extensible not to mention it slims down the application code drastically and development timelines.

There are a ton of code generation strategies but I'm a firm believe in the power of decoupling at the interface and not binding yourself to an implementation. With that said this generation code generates an injectable/autowireable manager, dao interfaces that extend a generic definition, genericized jpa implementations that extend an implementation specific generic dao (that happens to implement the same aforementioned dao interface as well).

If you have questions or need help with such things drop me a line. I'm more than willing to help especially considering the hibernate-tools code is not well documented nor is the context information passed into freemarker.

1 comment:

Andy O said...

Sounds sort of similar to the Repository pattern from DDD or PoEAA. Have you had a look at the Spring-Data JPA project (which came from the Hades project)?