ElementsFactory and css as static import instead of implements interface #879
Replies: 4 comments 4 replies
-
That has an huge impact on existing projects. Especially when you have to fix the imports in several hundreds of classes. |
Beta Was this translation helpful? Give feedback.
-
My preference is to not go with the is-a relationship here. I agree with the descriptions stated problems. The biggest one for me is with the IDE content assist as mentioned with Problem 3. It's very difficult to identify which methods are part of the widgets API vs the building block methods that are convenient only within the development of said widget. Possible Problem 4: My vote is to separate this out as utility methods. There could be some composite interface/class that's used to join those interfaces so that it's a one-stop shop for static imports. That way, the ElementsFactory, DominoCss, etc can continue the way they are today, but just not implemented everywhere. |
Beta Was this translation helpful? Give feedback.
-
can someone explain how the switch to static imports prevent the first problem, please. (may be I am blind?) |
Beta Was this translation helpful? Give feedback.
-
can you post an example of what the code would look like if you switched? As Frank mentioned this could affect quite a few files in my project. |
Beta Was this translation helpful? Give feedback.
-
When we started the new version of domino-ui 2 we wanted to reduce the amount of code you need to write as much as possible, and we managed to cut a lot of the boilerplate code for sure, one thing we did we made the ElementsFactory an interface that is implemented by default by all Domino-ui components, same for the Css interfaces -DominoCss- this was very convenient for sure it allowed us to write code like this :
We could create new elements or add css classes without the need to import any other classes.
But this came with some serious issues that affected other parts of the user experience :
Problem 1
It allows some weird syntax that might cause issues and errors that are hard to spot, for example in the following code :
On the Span element will be actually appended, the factory allowed a wrong chain of elements creation as the h and p elements will be discarded and only the last element in the chain will be used. this is sneaky in complex components or views that can go deep in the nesting.
Problem 2
Methods from ElementsFactory or Css classes from the Css interfaces will appear in the javadocs of every component, making it a very long scroll journey to reach the actual useful docs and makes it harder to find the docs we actually looking for.
Problem 3
Having all these methods as part of every component, causes problems to IDEs auto complete and hinting, since the list is extremely long it introduces tow mains issues here, the auto complete hints become very slow and it is way harder to get the result we expect.
With those issues in mind we are switching back to use static factory imports in the next RC release.
Please share your concerns and feedback on this topic.
Beta Was this translation helpful? Give feedback.
All reactions