2

When developing an application that separates into business logic and UI layer, is it ever wrong to use classes from UI packages? More specifically, is there any reason not to use the Property<T> classes from the javafx package?

The application in question is not very computation intensive, so I can deal with the overhead of the Property<T> classes. bind()ing values to one another provides a great deal of flexibility and would help with the control flow in my application, but it doesn't feel right to use a UI package in my business logic layer. The (very lose) reasoning behind that is, that they — apparently — have been designed for UIs. There must be a reason why they are not in java.util.


Bonus question: Why are the Property<T> classes in the javafx.beans package in the first place and not in java.util?

Neuron
  • 5,141
  • 5
  • 38
  • 59
  • Also [Usability of JavaFX Properties outside the scope of the GUI view](https://stackoverflow.com/questions/27315154/usability-of-javafx-properties-outside-the-scope-of-the-gui-view) – jewelsea Apr 24 '18 at 04:34
  • @jewelsea The second one truly does look like a duplicate – Neuron Apr 24 '18 at 04:36
  • But you specifically ask about properties in your question. What is the difference? – jewelsea Apr 24 '18 at 04:36
  • 2
    Be aware of the [JavaFX roadmap](https://blogs.oracle.com/java-platform-group/the-future-of-javafx-and-other-java-client-roadmap-updates) and check that that won't impact you. – jewelsea Apr 24 '18 at 04:38
  • @jewelsea Sorry, I didn't communicate that well. I meant the question is more related to *beans* and serialisation. – Neuron Apr 24 '18 at 04:41
  • 1
    JavaFX properties in the `javafx.beans` package rather than elsewhere is probably more historical than anything else. The binding concept for properties was central to the JavaFX architecture and it didn't exist in the core JDK, so it was developed for JavaFX before JavaFX was part of the JDK. When JavaFX was added to the JDK, JavaFX properties were already in the JavaFX namespace, so moving them to a `java.` namespace from a `javafx.` namespace would have been a breaking API change, so it wasn't done. – jewelsea Apr 24 '18 at 04:44
  • @jewelsea Thanks for linking the JavaFX roadmap. It does sound a bit messy if I only want to use the `Property` classes, but it should work.. – Neuron Apr 24 '18 at 04:55

0 Answers0