This conversation seems to be when the monks of the Middle Ages discuss how many angels can fit on the end of a pin. In other words, he begins to feel religious, unhelpful, and wrongly focused.
A mini rant appears (feel free to ignore):
If you do not want to continue reading. My short answer to the above topic: I do not agree with templates without logic. I think of it as a programming form of extremism. :-) :-)
Now my disclosure continues in full swing :: -)
I think that when you take a lot of ideas to the extreme, the result becomes ridiculous. And sometimes (i.e. this topic) the problem is that we take the “wrong” idea to the extreme.
Removing all logic from a view is a “ridiculous” and wrong idea.
Come back for a moment.
The question we need to ask ourselves is why do we need to remove the logic? The concept is obviously a separation of concerns . Keep view processing as separate from business logic as possible. Why do this? This allows us to change the view (for different platforms: mobile, browser, desktop, etc.), and it allows us to more easily exchange the control flow, page sequence, validation changes, model changes, access to security, etc. Also, when the logic is removed from the views (especially web views), it makes the views more readable and therefore more convenient for maintenance. I understand this and agree with that.
However, the focus should be on the separation of issues. Not 100% without logic. The logic in the views should relate to how to visualize the “model”. As far as I know, the logic in the views is absolutely beautiful. You may have a view logic that is not business logic.
Yes, back on the day when we wrote JSP, PHP, or ASP pages with little separation of code logic and viewing logic with or without it, serving these web applications was an absolute nightmare. Believe me, I know, I created and then supported some of these monsters. It was at this stage of the service that I really understood (visually) the error of my and my colleagues. :-) :-)
So, the edict from above (industry experts) has become, you have to structure your web applications using something like a controller in the foreground (which is sent to handlers or actions [select your web framework]), and your views should not contain code . Representations were supposed to be dumb patterns.
Thus, in general, I agree with the aforementioned feeling, and not on the specifics of the edict clauses, but rather on the motivation of the edict - this is the desire to distinguish between problems between the view and business logic.
In one project in which I participated, we tried to follow the idea without logic with an absurd extreme. We had a home template engine that would allow us to display model objects in html. It was a simple token based system. This was terrible for one simple reason. Sometimes in a view, we had to decide whether I should display this small piece of HTML .. or not .. The decision is usually based on some value in the model. When you have absolutely no logic in the presentation, how do you do it? Well, you can’t. I had some serious arguments in favor of our architect. The external HTML people who write our views were completely rooted when they encountered this, and were very stressed because they could not achieve their simple goals. Therefore, I introduced the concept of a simple IF statement in our template. I cannot describe to you the relief and calm that ensued. The problem was solved using the simple IF-Statement concept in our templates! Suddenly our template engine became good.
So, how did we get into this stupid stressful situation? We focused on the wrong goal. We followed the rule, you should not have logic in your views. This was wrong. I think the “rule of thumb” should be, minimize the amount of logic in your views. Because, if you do not, you may inadvertently allow business logic to penetrate the view - which violates the separation of concerns.
I understand that when you state that “you should not have logic in your views”, it becomes easy to find out when you are a “good” programmer. (If this is your measure of goodness). Now try to implement a web application of even medium complexity using the above rule. This is not so easy to do.
For me, the rule of logic in representations is not so clear and frank that I want it to be.
When I see a lot of logic in the views, I smell the code and try to remove most of the logic from the views - I try to ensure the life of the business logic elsewhere - I try to separate the problems. But when I start chatting with people who say that we need to remove all logic from the view, well, for me, this is simply amazing fanaticism, because I know that you can be in situations like those described above.
I ended up with my flatulence. :-)
Greetings
David