I am wondering whether this is the correct way to handle my situation when packaging-by-feature. Use the following project structure as an example:
com.foobar.web.Bootstrap.java
com.foobar.web.TcpServer.java
com.foobar.web.RequestHandler.java
Everything part of the web
feature is in the web
package - good so far. As all of the page classes are homogeneous and use the same parent, is it bad practice to then put them in a new sub-package by layer/type to avoid seemingly empty packages? In effect:
com.foobar.web.pages.AbstractPage.java
com.foobar.web.pages.HomePage.java
com.foobar.web.pages.BuyPage.java
com.foobar.web.pages.SupportPage.java
It feels almost as if I am packaging by feature then sub-packaging by layer. I find this hard to avoid unless I place each individual page in their own lonely package (e.g. .home.HomePage.java
, etc) which feels useless as they are on their own with no additional classes in their packages.
What is preferable, each in their own package .home.HomePage
(package by feature only) or all homogeneous in a single plural package .pages.HomePage
(package by feature, then type combined)?