In a previous article about ensuring success of your FatWire project, I focused mostly good content model design . Today I am focusing on appropriate template design: why you should design your templates before coding them, and how.
Why you need good template design
Once you have a good content model, it is time to go for designing the template hierarchy.
Actually, you need a design for templates. Fatwire has some requirements on template naming built-in in the underlying logic of their tags. Here is a post that tries to explain the underlying ideas of Fatwire template coding. Basically, in a good design, content model types looks like classes, while templates looks like methods.
Well designed templates have a simple name, the code is short and straight forward, and it is very easy to read. Fatwire tags for templates are very verbose, with an overwhelming number of options. But using them in a consistently way will make your code readable.
You can check FatPhone template source code for some examples of how template should be named and coded. Those examples are not actually my personal opinion but they follow closely Fatwire best practices, examples and recommendations (I was a trainer for FatWire).
Actually, some so-called "Fatwire developer" (people that not only don't take any training classes but don't even bore of reading manuals) don't understand the design. Well, they don't even understand the meaning of many parameters (for example the parent, the context, even the appropriate use of c and cid), and write templates badly.
The biggest and more frequent mistake I have seen are templates with very complex Java coding , whose structure and naming coded shows clearly the code don't understand there is an underlying caching system.
For example, they store a parameter as an attribute and they read it in another template that can be actually cached!!! The result lead to unnecessary long code and repetitive code, full of tricks written in Java. And, most important, those templates do not cache properly.
So here there are my advices.
Sadly, I have seen by far too many sites built this way.
The result normally is:
But I am sure it won't happen to you!