Its been at least 12 years since I last used Vaadin, and wow, it has come a long way.
I am interested in how others standardise their Vaadin code. For example, you can apply styles in three different ways, the java api, the getElement().getStyle().set(), and also addClassName()
What approach do you use and why have you chosen that approach?
In that specific case, I would suggest using the highest level of abstraction that works for you. This has multiple benefits:
Itâs easier to understand the intent behind the code. âEnable the âprimaryâ variant for this buttonâ vs âAdd this string to a list of of CSS class namesâ vs âUpdate the background color and the font colorâ.
It has fewer risks of mistakes due to typos when youâre using built-in constants instead of typing out string values.
It is more future proof since the exact mechanism for how a button is made as primary could be changed in the future and itâs then more likely that the concept of a âtheme variantâ still works whereas low-level mechanisms might be changed.