0

Long ago in my .Net projects (Desktop app) I used to three layer architecture and my folders structure was this:

Presentation - Business Logic - Data Access - Entity.

I was long been out of developing, now I'm developing a desktop apps (very simple) in javaFX. My problem is I don't know how structure the java packages.

In javaFX I should be forgetting about my old structure (UI-BL-DAL-Entity)?

For now I just have: two view .FXML with their respective controllers, main.class, person.class and conexion.class.

Can someone tell me how I should organize my project?

Sorry if is a silly question but...

1- I'm outdated

2- Projects in Java are new to me

3- I read JavaFx is MVC, I thought that was used just for web. I dont understand very well MVC I think is similar in separated logic like three layer but I believe that there is a fundamental difference that I do not know.

What I think..

M-> Data Access ?? my sql query?

V->my two .fxml ??

C->my two controllers ??

But my main class and my entities (Person.class) Where?

Wilfred Hughes
  • 29,846
  • 15
  • 139
  • 192
Ziggy Pop
  • 11
  • 4
  • "I read JavaFx is MVC, I thought that was used just for web." As an "old-timer", I have to say I find that really entertaining. MVC designs pretty much date back to Xerox PARC in the mid-70s (*decades* before web applications, even in the almost clairvoyant environment of PARC). The "web app" version of MVC is a bit different to "classical" MVC, and fits it over the top of the request-response cycle. I'd recommend reading the [wikipedia page](https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller) and [Martin Fowler's article](https://martinfowler.com/eaaDev/uiArchs.html). – James_D May 14 '18 at 13:24
  • https://stackoverflow.com/questions/3085640/best-approach-to-separate-model-view-and-controller https://softwareengineering.stackexchange.com/questions/115525/packages-organisation-with-mvc-design-pattern – fabian May 14 '18 at 13:28
  • Basically, though, all three MVC components are part of the presentation tier of your application. Your model will likely consist of a "central" model class which contains lists (or other data structures) of entities, and references the business layer, making calls to the business layer as required. The entities might be specific to the UI model (e.g. using JavaFX properties), or might simply reuse the entities from the domain. – James_D May 14 '18 at 13:28
  • For packages, I usually have one or more packages representing the model (`com.mycompany.myproject.ui.model`); and then I package the controller and FXML (and any specific supporting classes) for each of the view-controller pairs (`com.mycompany.myproject.ui.editor`, `com.mycompany.myproject.ui.mainview`, etc) with the FXML and controller both going in the relevant package. Obviously you can put multiple FXML-controller pairs in one package if you want coarser-grained packaging. Then other packages for your other tiers (service, data access, etc). – James_D May 14 '18 at 13:33
  • Also see https://stackoverflow.com/questions/32342864/ – James_D May 14 '18 at 13:34

0 Answers0