Throoze
Throoze

Reputation: 4038

Are there any standard for JavaFX directory/package structure?

I'm just starting to develop a javafx application, and i'm reading some tutorials. In those tutorials there are no mentions to good practices or propper (standard) ways to structure your app. Even though FXML documents provide a separation of the presentation layer, .fxml and .css files are stored in the same directory as .java files, and since I come from developing using frameworks like django and rails, the lack of a standard structure or layer separation disturbs me.

Is there any propper (more MVCish) way to structure a project? or is the one proposed by those tutorials the propper way?

thanks for your help, and notice that I'm not implying that that way is not correct. It's only that I'm used to the kind of structure proposed by popular web frameworks, and I would like to work like that with this new app (which is my grade project, btw).

Upvotes: 3

Views: 4135

Answers (2)

Marcel
Marcel

Reputation: 1768

There is no best Solution for this.

But an example way is:

Create a properly named package structure for java files.

Main java files (example: de.kogs.testapp)

Controller java files (example de.kogs.testapp.controller) and so on.

For fxml files:

example

fxml/main.fxml

fxml/slideouts/userSlide.fxml

Your pictures and css Files:

css/main.css

css/images/logo.png

Upvotes: 1

Ruben9922
Ruben9922

Reputation: 785

I usually have two packages: one for the FXML, CSS and controller files (ui) and another for the underlying Java code (could be named core, or something specific to the app like analysis or evaluator).

However, having all the UI files lumped into one package could become unwieldly, so one could (instead or additionally) split these files by type (into separate FXML, CSS and controller packages) as in Marcel's answer. Similarly, one could split the package containing the underlying Java code further too.

Upvotes: 1

Related Questions