26.07.2013 Views

Java How to Program Fourth Edition - DCC

Java How to Program Fourth Edition - DCC

Java How to Program Fourth Edition - DCC

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 8 Object-Based <strong>Program</strong>ming 411<br />

8.9 Software Reusability<br />

<strong>Java</strong> programmers concentrate on crafting new classes and reusing existing classes. Many<br />

class libraries exist, and others are being developed worldwide. Software is then constructed<br />

from existing, well-defined, carefully tested, well-documented, portable, widely available<br />

components. This kind of software reusability speeds the development of powerful,<br />

high-quality software. Rapid applications development (RAD) is of great interest <strong>to</strong>day.<br />

<strong>Java</strong> programmers now have thousands of classes in the <strong>Java</strong> API from which <strong>to</strong><br />

choose <strong>to</strong> help them implement <strong>Java</strong> programs. Indeed, <strong>Java</strong> is not just a programming language.<br />

It is a framework in which <strong>Java</strong> developers can work <strong>to</strong> achieve true reusability and<br />

rapid applications development. <strong>Java</strong> programmers can focus on the task at hand when<br />

developing their programs and leave the lower-level details <strong>to</strong> the classes of the <strong>Java</strong> API.<br />

For example, <strong>to</strong> write a program that draws graphics, a <strong>Java</strong> programmer does not require<br />

knowledge of graphics on every computer platform where the program will execute.<br />

Instead, a <strong>Java</strong> programmer concentrates on learning <strong>Java</strong>’s graphics capabilities (which<br />

are quite substantial and growing) and writes a <strong>Java</strong> program that draws the graphics, using<br />

<strong>Java</strong>’s API classes such as Graphics. When the program executes on a given computer,<br />

it is the job of the interpreter <strong>to</strong> translate <strong>Java</strong> commands in<strong>to</strong> commands that the local computer<br />

can understand.<br />

The <strong>Java</strong> API classes enable <strong>Java</strong> programmers <strong>to</strong> bring new applications <strong>to</strong> market<br />

faster by using preexisting, tested components. Not only does this reduce development<br />

time, it also improves programmers’ ability <strong>to</strong> debug and maintain applications. To take<br />

advantage of <strong>Java</strong>’s many capabilities, it is essential that programmers take the time <strong>to</strong><br />

familiarize themselves with the variety of packages and classes in the <strong>Java</strong> API. There are<br />

many Web-based resources at java.sun.com <strong>to</strong> help you with this task. The primary<br />

resource for learning about the <strong>Java</strong> API is the <strong>Java</strong> API documentation, which can be<br />

found at<br />

java.sun.com/j2se/1.3/docs/api/index.html<br />

In addition, java.sun.com provides many other resources, including tu<strong>to</strong>rials, articles<br />

and sites specific <strong>to</strong> individual <strong>Java</strong> <strong>to</strong>pics. <strong>Java</strong> developers should also register (for free)<br />

at the <strong>Java</strong> Developer Connection<br />

developer.java.sun.com<br />

This site provides additional resources that <strong>Java</strong> developers will find useful, including more<br />

tu<strong>to</strong>rials and articles, and links <strong>to</strong> other <strong>Java</strong> resources. See Appendix B for a more complete<br />

list of <strong>Java</strong>-related Internet and World Wide Web resources.<br />

Good <strong>Program</strong>ming Practice 8.6<br />

Avoid reinventing the wheel. Study the capabilities of the <strong>Java</strong> API. If the API already contains<br />

a class that meets the requirements of your program, use that class rather than creating<br />

your own. 8.6<br />

In general, <strong>to</strong> realize the full potential of software reusability, we need <strong>to</strong> improve cataloging<br />

schemes, licensing schemes, protection mechanisms that ensure master copies of<br />

classes are not corrupted, description schemes that system designers use <strong>to</strong> determine if<br />

existing objects meet their needs, browsing mechanisms that determine what classes are<br />

© Copyright 1992–2002 by Deitel & Associates, Inc. All Rights Reserved. 7/3/01

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!