In a project, certain related classes can be grouped together in one package. But some other useful classes are not related to any other class and so cannot be put into a package with any other classes.
A StackOverflow answer I read says that it isn’t a bad practice to put such classes in their own packages (just one class in a package), but somehow I feel this is not the best way to go.
So in such situations, what should be done with these unrelated classes?
2
Typically they should go in a util
or misc
package. But for example if you have a class DatabaseUtil
it can go directly under db
, supposing there you also have subpackages db.model
, db.dao
etc. for other database related classes.
I don’t find it at all suitable to have these classes each in its own package (that’s not what packages are designed for).
6