Danh mục

Hướng dẫn lập trình Java Style

Số trang: 13      Loại file: pdf      Dung lượng: 81.45 KB      Lượt xem: 6      Lượt tải: 0    
Thư viện của tui

Xem trước 2 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Các khuyến cáo được dựa trên các tiêu chuẩn thành lập (xem ví dụ [1], [2], [3], [4] và [5]), cũng như phản hồi từmột số lượng lớn các chuyên gia phần mềm trên thế giới.Hạn chế chính hướng dẫn hiện hành là những hướng dẫn viên đang ở xa quá chung chung trong phạm vi của họ và quy định cụ thể hơn(Đặc biệt là các quy tắc đặt tên) cần phải được thiết lập. Ngoài ra, các hướng dẫn hiện nay đã là một hình thức được chú thích mà làm cho nó dễ dàng hơn đểsử dụng...
Nội dung trích xuất từ tài liệu:
Hướng dẫn lập trình Java StyleJava Programming Style Guidelines Seite 1 von 13 Java Java Programming Style Guidelines V ersion 3.5, January 2004 G eotechnical Software Services C opyright © 1998-2004 T his document is available at http://geosoft.no/javastyle.htmlT able of Content 1 Introduction l ¡ 1.1 Layout of the R ecommendations ¡ 1.2 Recommendations Importance 2 General Recommendations l l 3 Naming Conventions ¡ 3.1 General Naming Conventions ¡ 3.2 Specific naming Conventions l 4 Files l 5 Statements ¡ 5.1 Package and Import S tatements ¡ 5.2 Classes and Interfaces ¡ 5.3 Methods ¡ 5.4 Types ¡ 5.5 Variables ¡ 5.6 Loops ¡ 5.7 Conditionals ¡ 5.8 Miscellaneous l 6 Layout and Comments ¡ 6.1 Layout ¡ 6.2 White space ¡ 6.3 Comments l 7 References1 I ntroductionT his document lists Java coding recommendations common in the Java development community.The recommendations are based on established standards (see for instance [1] , [2] , [3] , [4] a nd [5] ) as well as feedback froma huge number of software professionals around the world.Main drawback with existing guidelines is that these guides are far too general in their scope and that more specific rules(especially naming rules) need to be established. Also, the present guide has an annotated form that makes it far easier touse during project code reviews than most other existing guidelines. In addition, programming recommendations generallyt end to mix style i ssues with language technical issues in a somewhat confusing manner. The present document does notcontain any Java technical recommendations at all, but focuses mainly on programming style.W hile a given development environment (IDE) can improve the readability of c ode by access visibility, color coding, automaticf ormatting and so on, the programmer should never rely o n such features. Source code should always be considered l argert han the IDE it is developed within and s hould be written in a way that maximize its readability independent of any IDE.1 .1 Layout of the Recommendations.T he recommendations are grouped by topic and each recommendation is numbered to make it easier to refer to duringreviews.Layout for the recommendations is as follows:G uideline short descriptionE xample if applicableMotivation, background and additional information.http://geosoft.no/javastyle.html 18.02.2004Java Programming Style Guidelines Seite 2 von 13T he motivation section is important. Coding standards and guidelines tend to start religious wars, and it is important to statet he background for the r ecommendation.1 .2 Recommendation ImportanceI n the guideline sections the terms m ust , s hould and c an h ave special meaning. A must r equirement must be followed, as hould i s a strong recommendation, and a c an i s a general guideline.2 G eneral Recommendations1 . Any violation to the guide is allowed if it enhances readability.T he main goal of the recommendation is to improve readability and thereby the understanding and the maintainability andgeneral quality of the code. It is impossible to cover all the specific cases in a general guide and the programmer should beflexible.3 Naming Conventions3.1 General Naming Conventions2 . Names representing packages should be in all lower case.m ypackage, com.company.application.uiP ackage naming convention used by Sun for the Java core packages. The initial package name representing the domainname must be in lower case.3 . Names representing types must be nouns and written in mixed case starting with upper case.A ccount, EventHandlerC ommon practice in the Java development community and also the type naming convention used by Sun for the Java corepackages.4 . Variable names must be in mixed case starting with lower case.a ccount, eventHandlerC ommon practice in the Java development community and also the naming convention for variables used by Sun for theJava core packages. Makes variables easy to distinguish from types, and effectively resolves potential naming collision asin the declaration Account account;5 . Names representing constants (final variables) must be all u ...

Tài liệu được xem nhiều: