文档介绍:×÷Õߣºjeru
email: jeru@
ÈÕÆÚ£º8/9/2001 6:11:15 PM
Good Java Style: Part 1
By Thornton Rose
Introduction
Having worked as a software developer and consultant for many years, I have seen a large amount of code in a variety of programming languages. It has run the gamut from elegant to ugly, and unfortunately much of it has been ugly. I hope to persuade you, and my fellow developers, that we should give as much attention to the style of our code as we give to the user interface and other visible parts of an application. In this the first part of a two part series, I explain why we should care about how our code looks and illustrate some general elements of good Java style.
Why Style Matters
Even though Java is used to write programs rather than prose, it is still used to express thoughts and ideas. And, in addition to conveying information, those thoughts and ideas must actually do something. Worrying about good style may seem like a waste of time, but it behooves us to write our code such that the thoughts and ideas it expresses are exceptionally clear.
Here are several reasons for using good style [from "Java Code Conventions," Sun Microsystems]:
80% of the lifetime cost of a software product goes to maintenance.
Hardly any software is maintained for its whole life by the original author(s).
Using good style improves the maintainability of software code.
If the sour