Right now we're debating on two ways to structure our project
Decompose the project into modules and each modules contain the models, exception, controller it needs. So a user module might contain the User Model, all possible user exception cases for User, and the REST end point for dealing with User
Follows the traditional approach where we have top level models, services, controllers, exceptions. Then in services there will be sub packages and similarly in Exceptions.
Structure 1:
app/
/serviceA
/models
Foo.scala
/controllers
/exceptions
serviceA.scala
/serviceB
/models
Bar.scala
/controllers
/exceptions
serviceB.scala
Structure 2:
app/
/controllers
/models
Foo.scala
Bar.scala
/exceptions
/serviceA
/serviceB
/services
/serviceA
/serviceB
Is there a recommended project structure that features Exceptions, Services, Models?
The recommended "Play" way to structure your code is like this:
app
└ controllers
└ models
└ views
conf
└ application.conf
└ routes
modules
└ admin
└ conf/admin.routes
└ app/controllers
└ app/models
└ app/views
project
└ build.properties
└ Build.scala
└ plugins.sbt
See here: http://www.playframework.com/documentation/2.1.1/SBTSubProjects
In the above example, there's only one module called admin
, but you could add more in parallel with admin
.
Structure your code this way allows you to take advantage of built-in Play subproject features. For example, you could change the program context to admin
by simply typing:
project admin
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