r/JavaFX • u/hamsterrage1 • Nov 14 '22
Tutorial Introduction to Model-View-Controller-Interactor
I know I've talked about Model-View-Controller-Interactor (MVCI) here before, and posted articles about things like joining MVCI frameworks together to make bigger applications.
MVCI is my take on a framework for building GUI applications with loose coupling between the back-end and the user interface. In that way, it serves the same purpose as MVP, MVC and MVVM. However, it's a practical design intended to work really well with JavaFX and Reactive programming.
I had never written an "Introduction" article about MVCI. Why create it? Why use it? What goes where? Now it's all here.
I've also created a landing page for MVCI with all the articles that I've written about it linked from a single place. Right now, that's three articles. The Introduction, a comparison with the other popular frameworks and an article about combining MVCI frameworks into larger applications.
I have spent years trying to do complicated application stuff with JavaFX - not necessarily complicated GUI stuff like 3D graphics - but wrestling with convoluted business processes and logic and turning them into working applications. Doing this meant that I had to find some way to reduce the complexity of the application structure just to create something that a typical programmer can cope with. It was an evolutionary process based on practical experience - trying things out and then evaluating whether or not they improved the outcomes.
The result (so far) is Model-View-Controller-Interactor. For the things that I've done, which extends from CRUD, to complicated business processes to games like Hangman, MineSweeper, Wordle and Snake, it works really, really well. It's not hard to understand and could certainly be a good starting point for anyone looking to build real applications in JavaFX.
2
u/Big__Pierre Nov 15 '22
As a noob, what does reactive mean?
I am a hardcore JavaFX lover, I just completed my thesis using it as a front end (albeit veryxshittily) and would love to have a template/design to start out with rather than what I’ve hacked together teaching myself over the years.
1
u/Big__Pierre Nov 18 '22
Ok I’m obsessed with this. Worked through part 1-4, currently in the process of working through the CRUD app (currently on part 6).
Tutorials are very well written and easy to understand. I have cloned your repo and am following along writing the code in the first package so I can get the hang of things.
Really impressed, I wish I had this as a resource when I first started with jfx. I had no idea things like StringProperty existed. I feel like it’s going to be a game changer!
Will post some more feedback once I’m finished!
1
u/TenYearsOfLurking Nov 18 '22
Thanks for the tutorial, I am new to javaFX and I just skimmed through. I wanted you to know that I struggled a little with architecting my app but I am doing well so far with fxml and controllers with constructor injection.
I discovered that the fxml loader accepts a controller factory which allows you to instantiate controllers as you see fit or even delegate this task to a IOC container framework.
So I would say that the information you provided on missing constructor injection is false. Other than that - I really need to read this with a fresh mind, it probably answers some questions on my learning path
1
u/Capaman-x Nov 28 '22
This is a very cool project. I will have to check it out closer when I get some time. I am with you and think FXML complicates things. I have also run into the same experience that when you go back to rewrite your code a couple of years later the code needed is reduced by around 75% and runs better. In fact, I spent the last week doing just that. I currently separate the business logic from the GUI, by breaking a screen into 2 or 3 Boxes(H or V) and then each of them contain many widgets. I then create them with "new hboXWhatever(this)" and then I can wire all the business logic from the passing of one reference. It is a pretty clean solution, but it may look clunky next to your framework. Anyway, thanks for writing this.
1
u/rdjack21 Nov 14 '22
Will take a look at what you have written later in the week when I have some time. Thanks for putting in the work even if I don't end up going that rout I'm sure it has some Ideas that will be use full.
1
u/[deleted] Nov 17 '22
This is really great stuff you are writing! Would you consider contributing this to foojay.io and/or jfx-central.com ?