Qualified Names
Home ] Up ] [ Qualified Names ] The import Statement ] Automatic Import ] The package Statement ] Compilation Units ] Host Support for Packages ] Type Definitions ] Access Control ]

 

 

A solution is to organize code into named packages.

In C++, the feature equivalent to Java's packages is C++ namespaces.

Then, when class names conflict among different code libraries, we can explicitly place the code in separate packages, and qualify the name references with the appropriate package name.

The namespace represented is arranged hierarchically in terms of packages and sub-packages of a package, etc. For example, here is a reference to a method in the Java class library:

java.lang.String.substring()

where:

  • java is the package name
  • lang is the sub-package name
  • String is the class name
  • substring is the method name

And here is a (mythical) reference to a vendor's class library method:

COM.Aardvark.eng.gui.Menu.add(String s)

where:

  • COM.Aardvark is from the vendor's Internet domain name, aardvark.com
  • eng.gui is the vendor's internal naming convention:
    • eng -- Engineering
    • gui -- Graphical User Interface development
  • Menu is the class name
  • add is the method name within that class

Note that the convention is to use the organization's Internet domain names in reverse order. For example, common names might look like:

COM.Microsoft...
COM.Oracle...
COM.Borland...
COM.Symantec...

However, lots of vendors omit the COM., or just use their company name as the first name.

Also, some vendors use com, rather than COM.

 

This page was last modified on 02 October, 2007