Package heirarchy

T

Tim Tyler

Java lacks the notion of a package heirarchy.

All packages are in the same flat namespace as far as Java is concerned.

Also, there is no notion of a permission heirarchy.

You can have "visible from this package" and "globally visible" - but
there's no way to say "visible from these packages" - or "visible
"below" this point, but not from elsewhere.

This created obvious problems in creating encapsulation in large,
complex systems.

The problem needs fixing at the language level. However Sun shows little
sign of interest in this sort of surgery.

What Java /does/ have on this front is non-public classes and inner classes.

By putting classes within other classes, a heirarchy can be created.

"Unfortunately" all inner classes get access to their parents innards -
which is not always what you want if your aim is to create encapsulation.

Heavy use of such classes has a substantial down side, though - your
source files expand and it becomes harder to navigate them.

What I would like to see at some stage is an abstraction - that lets
you navigate into inner classes as though they were a tree - and
hides the details of the outer class from view when examining the
contents of inner classes.

This needs a fancy folding editor - or similar.

Also - perhaps - lint tools which check that "certain types"
of inner classes don't meddle with the workings of the outer classes.

In short I'd like to see inner classes become more usable as a way
of creating the sort of encapsulation that a package heirarchy is
supposed to be for.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top