Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

prefered mvc folder structure and classes

 
Ranch Hand
Posts: 173
2
Netbeans IDE PHP Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!

Please note first that this question is very basic regarding this topic.

I have just started to implement MVC patterns in my projects and I am a learner of those concepts. I'm very fresh to this subject so please forgive my erroneous assumptions and questions in this post. In one of my projects I have the following structure of folders:



  root --- ( the root folder. In netbeans - this is labeled with the name of my current application )
    |
    |
controller      --- In the controller-folder - what type of classes should I place here?
    |
    |
  dao          --- Here I intend to place all my database related classes
    |
    |
model        --- I understand the concept of the model part, but just for repetition, what type of classes should I place here?
    |
    |
resources    --- Folder with images and text-files.
    |
    |
 start        --- This is where I have placed the main class
    |
    |
 view       --- GUI classes goes here?


 

I am still reading tutorials on design with MVC-pattern. So far I have leaned only the basic concepts of each part. I am having some trouble with understanding of the structure and layout of folders and classes.
With that said I hope I can get some good advices and guide lines from skilled sources here.

Best wishes to all,
Robert!

 

 
 
Saloon Keeper
Posts: 22678
153
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no one-size-fits-all formula for this.

However, since many apps have a lot more complexity than that, they might further sub-divide. For exampls, model, view, and controller packages might be organized under "ui" or "gui". Some like to put model/view/and controller for a specific view in their own package, others just have general model, view, and controller packages.

Likewise, my webapps take the database packages and file them under "persistence". persistence.services is the high-level database code, persistence.dao has the table-level database code.
 
Robert Ingmarsson
Ranch Hand
Posts: 173
2
Netbeans IDE PHP Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply!

I see. Ok, so if I am going to use the formula like the one I have presented above, what type of classes should go in each of the above mentioned folders? This is something that I have read on but I wan't to take it from the beginning here. For instance is it correct to place all the gui classes in the controller folder, like my main frame and dialogs and panels?

 
Tim Holloway
Saloon Keeper
Posts: 22678
153
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Basically, whatever looks good to you.
 
Robert Ingmarsson
Ranch Hand
Posts: 173
2
Netbeans IDE PHP Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In MVC and accordingly to the pattern I made an ascii-drawing of, where would the best place be to hold and work with the ResourceBundle class?
 
Tim Holloway
Saloon Keeper
Posts: 22678
153
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about the "resources" directory?
 
Robert Ingmarsson
Ranch Hand
Posts: 173
2
Netbeans IDE PHP Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's the place where I keep the language files. What I meant was where do you do the localization part of the mvc sections? The setLanguage(String lang, String country) (custom method) and bundle.getString(String propertyName); Do you do this in the model, controller or the view? I am semi beginner at i18 stuff and doesn't know how this is done in real world applications. So far I do this in a separate class I call Localizer but how do you work with locales in a MVC environment?
 
Robert Ingmarsson
Ranch Hand
Posts: 173
2
Netbeans IDE PHP Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a side question about event classes in MVC. In a project of mine I have placed my Action objects in a controller class called FrancineController. Is that a valid approach in real life?
I instantiate them in a method called initActions().




 
Stinging nettles are edible. But I really want to see you try to eat this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic