Terence Parr is a very smart guy, and his article deserves special approval, but from a practical point of view, I found that the use of these constructions somewhat limits.
It is difficult to prevent business logic from being run, especially if you have the ability to do something, such as ASP.NET and JSP. It comes down to how you spend your time:
- Allow limited advanced features (I'm not a proponent of “nothing”) and use code verification mechanisms to ensure proper use or
- Limit the four constructs above and spend more time providing attributes such as
valueLessThanFive (remember to rename it to valueLessThanSix when changing business requirements or adding valueMoreThanThree - this is a bit appropriate as an example, but I think you'll know what i get).
In practice, I find that resolving conditional and circular constructs is useful, as it allows traversal of properties, such as attr[index].value in template expressions. This allows you to effectively manage presentation logic, while at the same time exposing yourself to a negligible risk of abuse.
Allowing more functions, such as calls to arbitrary methods, is becoming increasingly "dangerous" (in terms of facilitating misuse). To some extent, it comes down to a development culture in your environment, development processes, the level of skills and experience in your team.
Another factor is that in your environment you have the luxury to ensure a strict separation of work between presentation and logic in terms of the availability of specialized designers, not programmers, who would be delighted with the advanced designs in the template. In this case, you will probably be better off working with more limited template functions.
source share