r/JavaFX • • May 11 '23

Help Is there a javafx ecommerce framework?

As the title says I ambsearching for an ecommerce library if there is any since i want to ceeate my own webshop. So if u know any post. U get bonus points if it is opensource. Edit says check out https://github.com/mitvitaminen/crowear_hp to see what i am doing

5 Upvotes

14 comments sorted by

View all comments

Show parent comment

2

u/hamsterrage1 May 15 '23

With any GUI system you generally have two "states" that you need to represent in data; the application state, and the GUI state. The GUI state is generally referred to as the "Presentation Model", and the application state is generally thought of as the "Domain Model".

In JavaFX with MVVM, the Presentation Model is composed of observable objects that are bound to the various properties of the widgets that comprise the GUI. The ViewModel is responsible for preparing the Presentation Model and making it available to the View.

The Domain Model in MVVM is entirely contained within the Model. In order to avoid coupling, the Domain Objects that make up the Domain Model are hidden from the ViewModel, and the Model is responsible for supplying "Presentation Model ready" data to the ViewModel.

The division is pretty clear. The ViewModel and View have no exposure to the Domain Model in any way. The Model has no exposure to the Presentation Model in any way. Also, ALL of the business logic goes in the Model. ALL of it.

As a matter of fact, in MVVM I would expect that the Model would have no knowledge of JavaFX at all, and it would probably be considered "broken" if you even had any JavaFX imports in the Model class.

You can see from this that whatever framework you use for your e-commerce stuff cannot have any impact on the structure and functioning of the JavaFX GUI at all. Any data structures, annotations or referenced classes from the e-commerce framework have to be contained to the Model.

So the idea of a "JavaFX e-Commerce Framework" when you're using MVVM (or MVC for that matter) simply doesn't compute. Any attempt to inject e-commerce framework stuff into the JavaFX elements breaks the fundamental concepts of the MVVM/MVC architecture.

What you need to do is to use your e-commerce framework to maintain your Domain Model, and then build a mechanism in your Model to transfer changes to the Domain Model to/from the ViewModel so that it can reflect those changes in the Presentation Model, and visa versa.

Personally, I think you be best off building your Model as a "stand-alone" class that you can access from some test type classes to simulate what a GUI would do. Then, when you have the business logic worked out, and you know what method calls you need to make things happen, you can write the ViewModel and View.

1

u/mitvitaminen May 19 '23

I post u a github link later i am on the riad right now so u can check out my oroject as i already have it as u say i suppose but keep in mind that i just started and the Model is just done for the user class thanks for thw Detailed info though