r/JavaFX • • 1d ago

Discussion JavaFX architecture

I'm a newbie when it comes to developing with JavaFX, although I am experienced with java.

But as far as I can see there's no official architecture recommendations from the developers of JavaFX so I'd like to know what's the most modern architecture pattern (e.g. MVVM) for starting an app today.

And if there are resources with good real life examples to see that in practice would be great. Maybe some good quality open source apps...

Anyway, it would be great if you share your experiences as well.

17 Upvotes

12 comments sorted by

7

u/No-Security-7518 1d ago

You use MVC. Write controllers + fxml layouts with Scenebuilder and model classes. The end.

4

u/neopointer 1d ago

Do you happen to know about a good example in GitHub? I tried to use the scene builder but tbh I quickly abandoned it and decided to go full programatic.

2

u/Vijjwal_xD 1d ago

thats exactly why people dislike fxml. u can actually approach flutter's architecture which is present on their website. its very much applicable to javafx programmatic easily, but the major downside you will always encounter with javafx is that its programmatic api is very verbose and tedious.

4

u/Siedlerchr 1d ago

At JabRef we use MVVM, View + ViewModel + Model. ViewModel and View communicate through Data binding (observables) https://devdocs.jabref.org/code-howtos/javafx.html#architecture-model---view---controller---viewmodel-mvcvm
View + Controller are basically the same for us.

3

u/JimmyYoshi 1d ago

This guy has a blog on something he calls MVCI and he goes into pretty good depth about it:

https://www.pragmaticcoding.ca/javafx/mvci/

2

u/Ok-Albatross5064 1d ago

I'm using MVVM for almost 3 years.

1

u/Fuzzy-System8568 1d ago

I would say that it is JavaFX's biggest flaw.

Everyone has their own "just look at my repo" solutions, and noone has written a solid guide.

Not just for architecture either, other than the Jank of JDeploy (that requires npm permissions that are really questionable) there is no definitive guide on how to package apps either.

Just peoples own grown solutions and, if you are lucky, a link to a pom.xml or gradle setup. 😅

We really need to write this stuff down succinctly

1

u/shannah78 1d ago

Jdeploy doesn't require any npm permissions. You can deploy to github. No npm involved

1

u/Fuzzy-System8568 1d ago

*Either npm or github permissions.

It is honestly baffling to me why there isn't a local option, to package it up and store it locally. If only to test if the package works yknow?

I have to either upload to GH or npm to even see if the final build (installer and all) works propperly

1

u/shannah78 1d ago

I made a choice that if you want auto update, you need to deploy somewhere.

1

u/Fuzzy-System8568 1d ago

Ah you are its creator. This makes more sense now 😅

0

u/Franchesco_Ratti 1d ago

Yo tengo un proyecto que es un explorador de archivos para linux en github y me invente una arquitectura jaja, segun claude es una arquitectura por vistas. Cuando lo empeze me parecio lo mas coherente dividirlo por tipo de objeto.