RE: refactoring the velocity templates
Ronny Voelker <[email protected]> Tue, 13 Jan 2009 11:40:08 +0100
| Newsgroups | gmane.comp.java.scarab.devel |
|---|---|
| Message-ID | <[email protected]> |
hussayn wrote: Hi; >I want to start some basic refactoring work on the templates. So i took a >closer >look at the velocity files... > >Currently we do have a huge intertwinning between backend and frontend >and we even have some significant business logic right within the >velocity templates. And we do have 184 macro definition files, which smells >like >a huge amount of work. I feel with you. I once again was about to write a rant about the poor quality of most of Scarabs code base, because analyzing a seemingly simple bug (in choosing the sort-column for an issue-search) revealed a whole lot of flaws and the only sane choice to fix this flaws seemed a major refactoring. But I think we should refactor by functionality. I found it's not possible to refactor just a single tier without adding crap to another tier. For a good refactoring you need to understand the whole thing, from top to bottom. This is true especially for Scarab where we have no well designed API and obscure side-effects everywhere. This splits a large task into a couple of smaller tasks. It also helps to constraint the possible impact of the refactoring. In my bugfixing-effort I ended up refactoring the MITList-functionality which is still a big enough effort, but a lot smaller than refactoring all templates. >So how shall we start on this ? >1.) prepend "api_" to any reference to the java-api. > example: $api_SomeJavaClass > >2.) for java-references use the name of the associated class. > example: $api_ScarabRequestTool > What do you mean by Java-api? Would we also rename $user to $api_ScarabUser or $currentMitList to $api_MITList or $attributeId to $api_Integer? What do we gain? >3.) prepend "m_" to the name of a macro definition > example: #macro ( m_advancedQueryFunctionBar ) > >4.) for local macros (only used in the current .vm file) prepend "lm_" to >the name > example: #macro ( lm_onlyForLocalUsage ) Local macros are the ones defined it the current template. Global macros are the macros defined in the macro-templates. Why do we need a prefix to indicate this? Ronny -- Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet. This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. ------------------------------------------------------ http://scarab.tigris.org/ds/viewMessage.do?dsForumId=455&dsMessageId=1021592 To unsubscribe from this discussion, e-mail: [[email protected]].