Seeking advice about Java package naming

19 views
Skip to first unread message

David Pinn

unread,
Sep 13, 2017, 9:47:49 PM9/13/17
to Play Framework
The Play Framework 2.6 documentation has this to say about package naming:

There are three packages in the app directory, one for each component of the MVC architectural pattern:

  • app/controllers
  • app/models
  • app/views

You can of course add your own packages, for example an app/utils package.

Note that in Play, the controllers, models and views package name conventions are now just that and can be changed if needed (such as prefixing everything with com.yourcompany).


I'd like to keep my package naming structure flat: app.utils rather than com.mycompany.utils; but would I be inviting name collisions with dependent libraries?
 

Greg Methvin

unread,
Sep 14, 2017, 12:45:58 AM9/14/17
to play-framework
It's just a suggested practice to minimize collisions. Because other libraries typically follow the reverse DNS naming scheme, you're unlikely to encounter collisions with other libraries if you use something like "app.utils".

If you decide to release your library publicly I would strongly encourage you follow the reverse DNS scheme, though.

--
You received this message because you are subscribed to the Google Groups "Play Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/81db949e-bda9-43db-aede-0d3749bc2478%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Greg Methvin
Tech Lead - Play Framework

Daniel Jue

unread,
Sep 14, 2017, 4:08:39 AM9/14/17
to Play Framework
I agree, and if you think it will grow to a large or accredited project, it will be nice to have your reverse DNS name match the cert that you'll use for your site.  I can tell you at one of my jobs we had assumed we owned the .com when it was actually being squatted on by some other company.  We had to get a .io version for our certs, and some of our teams were really inclined to change the namespaces to match .io for code signing and secure boots, etc.

Reverse dns namespace mapping across your codebase will help you reason about log filters and highlighting where in -your- codebase exceptions come from.  It's also a very polite thing to do for new developers to understand your code vs some other group/partner/department.

Dan


On Thursday, September 14, 2017 at 12:45:58 AM UTC-4, Greg Methvin wrote:
It's just a suggested practice to minimize collisions. Because other libraries typically follow the reverse DNS naming scheme, you're unlikely to encounter collisions with other libraries if you use something like "app.utils".

If you decide to release your library publicly I would strongly encourage you follow the reverse DNS scheme, though.
On Wed, Sep 13, 2017 at 6:47 PM, David Pinn <dp...@byandlarge.net> wrote:
The Play Framework 2.6 documentation has this to say about package naming:

There are three packages in the app directory, one for each component of the MVC architectural pattern:

  • app/controllers
  • app/models
  • app/views

You can of course add your own packages, for example an app/utils package.

Note that in Play, the controllers, models and views package name conventions are now just that and can be changed if needed (such as prefixing everything with com.yourcompany).


I'd like to keep my package naming structure flat: app.utils rather than com.mycompany.utils; but would I be inviting name collisions with dependent libraries?
 

--
You received this message because you are subscribed to the Google Groups "Play Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages