I’m studying ASP.NET Core and came across the tag helpers when I generated the scaffold of a view . I found the new syntax interesting, the code is more readable on some points, however, adding another DLL to all views that used tag helpers can not end weighing in the project?
What other advantages or disadvantages can be highlighted in relation to tag helpers ?
Note: Searching a little on Google found this topic in SOen , however I found it interesting to keep the question for a discussion on the subject in Portuguese.
In general this extra weight is not significant and basically if not use, the weight may even be higher in some cases.
The main advantage you have already noticed is the readability of the code. This has to do with better abstraction. It also helps to be encapsulated and make it easy to change some detail of the final HTML code without having to tinker with every page. Great for evolving HTML within new standards and practices. Remember that the tag helper is a method, it has all the benefits of this element of building codes.
The main disadvantage is that you lose control of the code to use. If the helper is very specific or very general, it makes it useless for most cases, so it is difficult to find a balance than by its code. For simple things it is easy to use. Some settings are possible, albeit limited, if the specific helper is built with this in mind. Although this may start to complicate the code and make readability pro space.
They may not interact well with all view constructs. This depends on the quality of helper , but it can not work miracles.
Like all resources if you do not know how to use them properly, you know how to use creativity to make it really useful, it’s best not to use it. Of course, using existing ones should not be a problem, but creating your own helpers requires a bit of experience not to make mistakes and diminish their usefulness.