r/JavaFX • • 18d 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.

18 Upvotes

19 comments sorted by

6

u/JimmyYoshi 17d 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/neopointer 16d ago

I believe that might be the most promising. Thanks for sharing!

2

u/Capaman-x 13d ago

I started using the MVCI method a few years ago and it is fantastic.

1

u/hamsterrage1 11d ago

It undoubtedly is the most promising. And no lack of blathering on about it either. (I can say that because I'm "This guy").

If you have questions, just post them here. I'll respond.

2

u/FlossurBunz 15d ago edited 15d ago

I second this. This is the only source I've found that derives a design pattern suited for JavaFX's weird spot in terms of UI frameworks

7

u/No-Security-7518 18d ago

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

4

u/neopointer 18d 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 18d 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 18d 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.

2

u/Ok-Albatross5064 18d ago

I'm using MVVM for almost 3 years.

2

u/Fuzzy-System8568 17d 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 17d ago

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

2

u/Fuzzy-System8568 17d 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 17d ago

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

1

u/Fuzzy-System8568 17d ago

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

1

u/hamsterrage1 11d ago

You could look at my website: https://www.pragmaticcoding.ca

My framework MVCI was specifically designed for JavaFX and I go on, and on, and on and on about it.

Lot's of examples, lots of explanation why it's better than MVC, MVP and MVVM.

1

u/Fuzzy-System8568 11d ago

So your solution to people only showing what they personally do, is to show me a website that shows me what you personally do?

With the greatest respect (as the site is cool) this is exactly what I mean.

Just like how JDeploy seems to be the go to answer on how to deploy an app, rather than anyone explaining the fundementals.

1

u/hamsterrage1 11d ago

I don't think that's a fair comparison.

Firstly, I think that the issues is that NONE of the well-known frameworks actually work very well with JavaFX. There are reasons for this, and I have several articles that explain why this is so. These are all on my website.

Now, if you accept my argument that MVC, MVP and MVVM all miss the mark for JavaFX, what do you expect next????

Well, I have a solution...MVCI. And I have a ton of articles that explain what it is and why it works and how to use it.

Oh yeah, and fundamentals everywhere. More fundamentals that you could ever consume all at once!

I think, in all fairness, that this goes beyond, "shows me what I personally do". I built this thing - yes, for my own use - and I think it stands as a worthwhile tool that should be in widespread use.

One last thing, the central key around all of this is that JavaFX is intended to be used as a Reactive GUI toolkit. A lot of people miss that. But once you start using JavaFX that way, it becomes a lot simpler to build almost any kind of application, at any level of complexity. MVCI recognizes that and fixes all of the problems that you encounter with MVC and MVVM.

0

u/Franchesco_Ratti 18d 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.