I just started developing in Java after not having touched it since my college days. So far I've been able to remember a lot of things and read up on a whole bunch, this one is still not clear to me...
The problem I'm having is that a lot of books/examples/tutorials/SE posts focus on simpler, smaller problems where this type of question would not occur.
If you have a project with 1000's of types (classes, interfaces or both)... is the best project structure/layout convention to simply create a new file for each type? Coming from C++/C# background, that doesn't sit well with me (yet?) as I'm used to typically having one, or maybe few, files that would define interfaces used throughout the rest of the project. And small, related classes would often be implemented in one file.
As a more concrete example, I am currently refactoring an "Event" class which currently is handling 15 different event types, all in one class. The package where the class is defined also has other event-handling classes, such as readers, writers and parsers.
If I create base event class and 15 deriving classes, as each one has slightly different attributes/behaviors... these are my options:
Having not enough Java experience, I just can't decide which approach is an accepted standard. Is it ok to have 1000's of files in one directory? Should I create more packages? (looking at other libraries/frameworks, it appears that they keep number of packages to a minimum)
In other cases, especially when implementing a strategy pattern, i would create one public base class with a static factory method and a number of non-public classes just so I could keep them in one file. Seems I'm making these "design" choices only based on this one public type per class rule and everything time I do that, this question comes back... maybe I'm just not doing it right.
Having to get over the idea of "too many files" is common among programmers coming to java from other languages.
There are special cases where you might want to have, say, a static inner class that you make public (see Map.Entry, for example), but generally, you want to stick with one class (one source file) per public class.
It certainly makes sense to create sub-packages when classes can logically be sub-grouped. Don't be afraid of creating "too many" packages either.