You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
HTML is structured in hierarchical style, it is elements inside elements inside elements...
this structure allows you to locate the elements inside the page, and domino-ui with the builder/fluent api like
so lets compare the following code sample that builds the above card.
It is completely valid to write domino-ui code using style 1. but for my own preference there is a lot of extra typing and it does not reflect the structure and the hierarchy of the html, even in this very simple sample it is still hard to tell what goes into what and for something bigger it can be easily turn into a mess over time.
In the style 2. it looks simpler with less typing and it does reflect the structure and it is somehow much easier to locate the components inside each other and it is a lot easier to move components and relocate them inside this structure. but if it is a very big tree this will be a little overkill, specially if each component initialization took a lot more than few lines of code or even had it is own nesting, lambdas or loops..etc. also this style impose debugging issue when we set breakpoints.
So in a real project we adopted a middle ground style as we actually initialize the component outside the structure and append the components using style 2.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
In order to answer this question we need to think of HTML before we think of the domino-ui java code we write , so lets start with simple example :
Which would look like this in the browser
HTML is structured in hierarchical style, it is elements inside elements inside elements...
this structure allows you to locate the elements inside the page, and domino-ui with the builder/fluent api like
so lets compare the following code sample that builds the above card.
It is completely valid to write domino-ui code using style 1. but for my own preference there is a lot of extra typing and it does not reflect the structure and the hierarchy of the html, even in this very simple sample it is still hard to tell what goes into what and for something bigger it can be easily turn into a mess over time.
In the style 2. it looks simpler with less typing and it does reflect the structure and it is somehow much easier to locate the components inside each other and it is a lot easier to move components and relocate them inside this structure. but if it is a very big tree this will be a little overkill, specially if each component initialization took a lot more than few lines of code or even had it is own nesting, lambdas or loops..etc. also this style impose debugging issue when we set breakpoints.
So in a real project we adopted a middle ground style as we actually initialize the component outside the structure and append the components using style 2.
With this style achieved less typing, separate initialization, and structured components, we have less debugging issues and easier refactor.
So in fact anyone can use the style they prefer and even come with their own preferred style.
Beta Was this translation helpful? Give feedback.
All reactions