• Post Reply Bookmark Topic Watch Topic
  • New Topic

Advice on Project Organization?  RSS feed

 
Stevens Miller
Bartender
Posts: 1444
30
C++ Java Netbeans IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have created a package for my project, called "com.dumblux.filters4." In my NetBeans IDE, it displays its files like this:



Most of those files define classes that are package-private. The public classes are these:



I'd like to isolate those public class files from the others. But, if I put them into a package of their own, they lose access to the package-private files they need to compile, and I don't want to make those all public. I could prepend them each with some unique string, like "DL" or something, rather like that "J" that prepends Swing classes. They'd all group together in the Project window, at least. But that "J" business has always seemed kind of rinky-dink to me (in the legal profession, we would say, "baggy-pants," if that helps make "rinky-dink" any clearer).

Anyone have a suggestion on how I can organize my files so the public classes are grouped together, but don't lose access to the package-private classes they need to compile?
 
Stephan van Hulst
Saloon Keeper
Posts: 7821
142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Stevens,

I wouldn't change the semantics of your project just because you don't like the way your IDE lays it out.

Keep in mind that only public classes need to be in a file with the same name. You could add a prefix to the file names of your package private types (something like "z"), without having to rename the types themselves.
 
Stevens Miller
Bartender
Posts: 1444
30
C++ Java Netbeans IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephan van Hulst wrote:You could add a prefix to the file names of your package private types (something like "z"), without having to rename the types themselves.

Oh, yeah. I hadn't thought of that, but you're right.

Heh, trying that in NetBeans, it won't let me do it. The IDE insists that, if a file contains a class with the same name, they have to match. Obviously, that's not a Java requirement. That's just something the good folks who wrote NetBeans decided to impose. Outside of NetBeans, I can just rename, say "CommandPin.java" to "_CommandPin.java," and it sorts towards the bottom (makes me feel like I'm programming in C++, too ).

Not a bad possibility. Any others?
 
Stephan van Hulst
Saloon Keeper
Posts: 7821
142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, NetBeans is highly customizable, so you could write a plugin that reorders the project nodes, but I'm not sure if that's worth your time.
 
Stevens Miller
Bartender
Posts: 1444
30
C++ Java Netbeans IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now that's an interesting idea. It does this in other places (the Navigator groups by access level, for example), and sort of half does it for packages, as the little glyphs next to the file names vary according to whether the matching class name is abstract, concrete, or an interface. It doesn't group them, nor is it basing those glyphs on access levels, but it clearly is peeking into the files. Wouldn't be impossible, I suppose, to add an annotation that simply declared a file to be part of my public API, and have the Project window sort those into one group.

Yes, a fine project for when I have some free time...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!