I am learning Play! 2 for Scala, coming from a Django background. In Django I was used to being able to modularize a project by dividing it in various applications, each having its own models, views, controllers and assets. Does Play! allow a similar subdivision of a project or it is mandatory that everything goes under the app
directory?
EDIT I already got the answer, but I will make some examples of the use of Django apps:
and so on
Modules can be stored in separate files, and function and constant names will be unique to each file, but not the whole program. And modules can be easily re-used in different projects, without copying and pasting.
A project with multiple Gradle modules is known as a multi-module project. In a multi-module project that ships as a single APK with no feature modules, it's common to have an app module that can depend on most modules of your project and a base or core module that the rest of the modules usually depend on.
One rule of thumb is that you can often split the application into modules based on package boundaries. Thus, if you have the following packages: You might refactor this into a GUI module, a data module and a logic module. As you continue development, you might find that these could be split even further.
One rule of thumb is that you can often split the application into modules based on package boundaries. Thus, if you have the following packages: com.tomwheeler.app.gui. com.tomwheeler.app.data. com.tomwheeler.app.logic. You might refactor this into a GUI module, a data module and a logic module.
Also, a component (or ... you got it) can only be declared in one module. If you want to use your component in multiple modules, you need to bundle that component into a separate module and import that in the module. Speaking of importing... Your module can import as many sub-modules as you like. Don't have defined any custom modules yet?
In general, I definitely prefer to have lots of little modules than a few big ones. If you're designing a new app from scratch, it's easy to achieve "smallness" in your modules and you'll have a better design (less coupling) because of it.
Maybe sub-projects are what you need. It would help if you would describe a little why you want to modularize and what a module should consist of from your point of view.
Just a little update on the thread. From 2.1 Play supports routing mapping of sub-modules:
https://github.com/playframework/Play20/blob/master/documentation/manual/Highlights.md#allow-more-modularization-for-your-projects
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With