r/JavaFX • • 6d ago

Discussion JavaFX application by a back-end developer

https://andrej-urvantsev.statichost.page/posts/2026-11-17-javafx/
28 Upvotes

10 comments sorted by

10

u/sombriks 6d ago

Nice article, thanks for sharting!

In my own experiments i got into reactive/signal-based interfaces and got recommended here this article: https://www.pragmaticcoding.ca/javafx/techniques/reactive-javafx/

Note that "reactive programming" in the context of modern frontend does not relate to that collective hallucination that backend java suffered back in Vert.x days.

7

u/Wootery 6d ago

thanks for sharting

(¬_¬)

3

u/lazystone 6d ago

/u/sombriks please don't fix this. It's my favorite typo now!

2

u/sombriks 5d ago

hahaha, i have a secret, english is not my main language and i am legally blind!

But i hope that the original message lands right!

4

u/OddEstimate1627 6d ago

DI in JavaFX is actually very common. Adam Bien was advocating for FXML + DI via Afterburner.fx back in 2014, and a lot of developers used it and developed it further (e.g. FxmlKit).

FXML itself is also just DI on the UI layer, except that you use the FXML annotation and override initialize() instead of Inject and PostConstruct.

1

u/Wootery 6d ago

Can't say I'm sold on the DI framework but at least it's compile-time.

Formatting gripe: the way the -> operator renders as a single character. This makes it look as if a unicode arrow character has mistakenly been used. Code should be shown using a monospace typeface with no cute formatting tricks.

3

u/lazystone 6d ago

That's exactly how it looks like in my IDE(I love font ligatures). Matter of taste.

3

u/PartOfTheBotnet 5d ago

DI is something that you come to love after you work on an application that really benefits from it.

1

u/Wootery 4d ago

What's the advantage of a DI framework over just accepting a parameter of interface type where appropriate?

Wikipedia's discussion is disappointingly uninformative. It's not at all clear why whole frameworks are justified when we already have plain old interface types.

3

u/PartOfTheBotnet 4d ago

What's the advantage?

It boils down to: "Wow, this is incredibly freeing not having to worry about bullshit wiring all over the place. If I want to add a thing, I just add it. I don't have to worry about ceremony."

Bullet points because otherwise this would be an even bigger wall of text:

  • Framework not needed in a small app. Heck, DI principles aren't needed if its a one-and-done.
  • DI principles come into play to keep code clean, extensible, easily testable.
  • Frameworks solve wiring complexity / ceremony + maintenance.

    • In turn, this makes writing features easier, as you just focus on the feature, not boilerplate connecting logic.
  • Frameworks can make writing tests with with mocking relatively easy.

    • At work in a JUnit class, I just do @Mocked IFooService foo and it hooks the creation of that type to use my mock, which I can configure with Mockito.
    • Super useful for swapping out "live" impls with stubs, like a REST client service with test-defined responses
  • Wikipedia discussion points are largely outdated, per the "disadvantages":

    • Demanded configuration: Framework dependent. Most CDI frameworks in java are fine with defaults, so nothing onerous like wiki states.
    • Tracing hard due to separated behavior / construction: Issues generally aren't because of this separation. They generally are logic+behavior problems (not DI's fault) or construction problems (your usage of DI being wrong's fault). In both cases, tracing with a debugger like IntelliJ's has never been an issue. Construction failures are generally clear. Hey, A requires B, and B requires C, but C isn't available because the C failed to initialize (Generally some failure in the class's static initializer)
    • Hindered IDE automation: Exact opposite with IntelliJ. It builds around CDI as a feature, making it rather nice.
    • Upfront effort: Depends on framework. Most of the time, this is handled by creating a project from a template anyways. Its rare for a dev to manually flesh out a full build.gradle or pom.xml.
    • Dependence on framework: For initialization of the CDI container, sure. But outside of that, basic usage can get away with standardized types like those defined in JSR-330.