Working with Existing Objects
One of the things you have learned about object-oriented coding is how it encourages reuse. If you develop an object for use with one Java coding project, it should be possible to incorporate that object into another project without modification. If a Java class is well-designed, it's possible to make that class available for use in other programs. As long as the class is documented thoroughly, a programmer should be able to work with that class as if it were part of the official Java language itself. This is an idea that has great potential for software developers. The more objects available for use in your programs, the less work you have to do when creating your own software. If there's an excellent spell-checking object that suits your needs, you can use it instead of writing your own. Ideally, you can even give your boss a false impression about how long it took to add spell-checking functionality to your project, and use this extra time to make personal long-distance calls from the office.
By the Way
The author of this tutorial, like many in his profession, is self-employed and works out of his home. Please keep this in mind when evaluating his advice on how to conduct yourself in the workplace.
|
When Java was first introduced, the system of sharing objects was largely an informal one. Programmers developed their objects to be as independent as possible and protected them against misuse through the use of private variables and public methods to read and write those variables. Sharing objects becomes more powerful when there's a standard for developing reusable objects. The benefits of a standard include the following:
- There's less need to document how an object works, because anyone who knows the standard already knows a lot about how it functions.
- Development tools can be designed that follow the standard, making it possible to work more easily with these objects.
- Two objects that follow the standard will be able to interact with each other without special coding to make them compatible.
|