0
votes

I'm writing a Java library that has a simple interface, but a lot going on behind the scenes. In order to keep the API surface small, I've kept the library as one large package (so that I can make most classes package protected). Now that the library has grown, it's become a little difficult to find the class you're looking for.

Is there any way to visually organize a lot of classes in the same package?

I know that in general, creating a new directory also creates a new package. Is there any way around that? Is it at all possible to have multiple directories that are all in the same package?

If not, I'm also open to any creative ways to visually organize the classes (I've considered prepending class names with the "package" it would be in, but I don't think that helps much).

If there are any solutions involving some sort of IDE tags, that would be acceptable too (we use IntelliJ).

Thanks!

Say everything is in package com.company.a, just create subpackages like com.company.a.ui, com.company.a.backend, etc. - Jim Garrison
This isn't a great question, it isn't clear why you need to do this. Most people don't have a problem with a directory structure and package name being the same. IDEs have shortcuts to make classes fast to find and directories are generally accepted as a reasonable way to organize. - DCTID
@JimGarrison Creating subpackages won't work, because then you lose the ability to use package protection. I wish there was a "superpackage protection" visibility. - user1902853
@DCTID I tried to explain in the question, but here's more context: We're adding more developers to the team, and so while I have a good understanding of what all ~150 classes do, they don't. Some sort of organization would be useful. However, moving them into subpackages prevents you from using package protection. It seems like there must be some other answer. - user1902853
If you have a large package and are depending on package-level scope, then you have some very serious coupling problems. That is an anti-pattern. It's global variables, just on a smaller scale. - Jim Garrison