Home > Articles > Programming > Java

  • Print
  • + Share This
From the author of

Ubiquitous Code

Some packages are so highly coupled that you have to assume that they're found everywhere. A prime example is java.lang, which contains a number of classes that you can hardly do without, such as String and Exception . Every program is tightly coupled to it, so Java relieves you of some of the problems associated with tight coupling by automatically importing it into every class, and providing it with every program.

Other packages are almost as universal. The java.util and java.io packages are used in nearly every Java program, but not all. The J2ME CLDC (Connected Limited Device Configuration) platform lives without large subsets of java.util, such as the whole hierarchy rooted at Collection. Such classes decrease the cohesion of java.util, as demonstrated by the fact that you can just do without them on some platforms.

Outside of those three packages, package coherence allows the J2ME specification to specify what's in the J2SE that's not in the J2ME, such as all of the javax and java.awt packages. The CDC (Connected Device Configuration) adds in some other packages, for example the java.text package.

  • + Share This
  • 🔖 Save To Your Account