Java’s naming system supports a hierarchical structure.
In the context of the system, the subcomponents will have names that are qualified by the components they belong. Ex dj.browser.Protocol
A Java program is organized into packages. Each class or interface has its own file. Packages are mirrored in the directory structure. Just like directories, packages can be nested arbitrarily deeply. To organize your code into packages:
Indicate at the top of each file which package its class or interface belongs to.
Organize the files physically into a directory structure to match the package structure.
The class dnj.browser.Protocol would be in a file called Protocol.java in the directory dnj/browser.
We can show this structure in a dependence diagram:
Packages are shown as contours enclosing them. It’s convenient sometimes to hide the exact dependences between parts in different packages and just show a dependence arc at the package level.
Copyright © 1998-2009 Dilvan Moreira