[stringtemplate-interest] Separation of View and Biz Logic

Bill Venners bv-svp at artima.com
Wed May 16 00:19:23 PDT 2007


Hi All,

We are migrating some velocity templates to ST, and in the velocity  
templates we had been calling some static utility methods to do  
things like uppercase the first char, lowercase the first cahr  
transform a camel case word (like employeeStartDate) into a constant  
form (like EMPLOYEE_START_DATE)--things like that. Rather than make  
separate variable for each form, we were thinking of making a utility  
class whose instances take a String. Then there are get methods for  
each of the permutations, like getWithFirstUpper(), getWithFirstLower 
(), getInCamelCase(), getInConstantForm(), etc. So it could be  
accessed inside an ST template with employeeStartDate.withFirstUpper  
or employeeStartDate.inConstantForm. The toString method on this  
object would just return the String passed to the constructor. We  
would encapsulate relevant String variables inside instances of this  
class, then pass those to the template instead of the raw Strings.

This seems perfectly reasonable way to do this, but I wanted to check  
whether it violated anyone's sense of strict separation between view  
and biz logic.

Thanks.

Bill
----
Bill Venners
President
Artima, Inc.
http://www.artima.com





More information about the stringtemplate-interest mailing list