亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? good java style part 1.txt

?? 一個新的采集工具 一個新的采集工具 一個新的采集工具
?? TXT
字號:
作者:jeru
email: jeru@163.net
日期: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 source code is shipped with the software, it should be as well-packaged, clean, and professional as the rest of the product. 

Writing code with good style also provides the following benefits: 


It improves the readability, consistency, and homogeneity of the code, which makes it easier to understand and maintain. 
It makes the code easier to trace and debug, because it's clear and consistent. 
It allows you to continue more easily where you or another programmer stopped, particularly after a long period of time. 
It increases the benefit of code walkthroughs, because the participants can focus more on what the code is doing. 

General Guidelines
Writing Java with good style is not hard, but it does require attention to detail. Here are some general guidelines to follow: 


Make the code clear and easy to read. 
Make the code consistent. 
Use obvious identifier names. 
Logically organize your files and classes. 
Have only one class per file (not including inner classes). 
Use a maximum line width of 80-90 characters. 
Use whitespace and/or other separators judiciously. 
Use spaces instead of tabs for indentation. 

Tabs vs. Spaces
Tabs vs. spaces is one of several religious issues related to writing code, and I am not suggesting that there is only one right way. I espouse using spaces because it ensures that my code will look the same in my editor as it does in your editor and vice versa. If you feel that using spaces instead of tabs "just ain't right", then by all means use tabs. 

Braces and Indentation
Indent style (cf., Raymond, "Indent Style"), or the placement of braces ("{" and "}") and the associated indentation of code, is another of the religious issues related to writing code. There are several indent styles common to C-style languages like Java, and I am not going to suggest that one of them is superior. In most of the example code in this article, I use what is usually referred to as K&R style. If you don't like K&R, by all means use another style.

Comments
There are two type of comments that you can put in your Java code: Javadoc comments (also called documentation comments) and implementation comments. Javadoc comments can be extracted by the javadoc tool to produce API documentation. Implementation comments are those comments that explain the how and why of the code. Use the following guidelines for commenting your Java code: 


Use Javadoc comments wherever they are allowed (on classes and methods at minimum). 
Use block comments rather than end-of-line/trailing comments, except in special cases, such as variable declarations. 

Also, keep in mind that good comments are helpful; bad comments are a nuisance. 

Example 1. Bad Comment Style


   // applyRotAscii() -- Apply ASCII ROT
   private void applyRotAscii(){
      try{
         int rotLength = Integer.parseInt(rotationLengthField.getText().trim()); // get rot len
         RotAscii cipher = new RotAscii(rotLength); // new cipher
         textArea.setText(cipher.transform(textArea.getText())); // transform
      }catch(Exception ex){ 
         /* Show exception */
         ExceptionDialog.show(this, "Invalid rotation length: ", ex); }
   }


Example 2. Good Comment Style.


   /**
    * Apply the ASCII rotation cipher to the user's text. The length is retrieved
    * from the rotation length field, and the user's text is retrieved from the
    * text area.
    *
    * @author Thornton Rose
    */
   private void applyRotAscii() {
      int      rotLength = 0;  // rotation length
      RotAscii cipher = null;  // ASCII rotation cipher
   
      try {
         // Get rotation length field and convert to integer.
          
         rotLength = Integer.parseInt(rotationLengthField.getText().trim());
         
         // Create ASCII rotation cipher and transform the user's text with it.
          
         cipher = new RotAscii(rotLength);
         textArea.setText(cipher.transform(textArea.getText()));
   
       } catch(Exception ex) {
         // Report the exception to the user.
         
         ExceptionDialog.show(this, "Invalid rotation length: ", ex);
      }
   }


Blocks and Statements
Use the following guidelines for writing blocks and statements: 


Put only one statement per line. 
Always use braces with control statements (e.g., 'if'). 
Consider marking the end of a block with a comment (e.g., } // end if), particularly with long or nested blocks. 
Put variable declarations at the beginning of a block. 
Always initialize variables. 
If you want to be a perfectionist, left-align variable names. 
Indent the case clauses in a switch block. 
Put whitespace before and after operators. 
In if, for, or while, put whitespace before the "(". 
Use whitespace and parentheses in expressions to increase readability. 

Variables used in 'for' loops are the exception to putting variables at the beginning of a block. The loop variable(s) may be declared in the initialization part of the for statement, e.g., for (int i = 0; ...)
 
. 

Putting a comment at the end of a block can help you track down accidentally deleted closing braces. Finding those in a large source file can sometimes drive you nearly crazy. 

Example 3. Bad Block Style.


   try{
      for(int i=0;i<5;i++){
         ...
         }
      int threshold=calculateThreshold(); 
      float variance=(threshold*2.8)-1;
      int c=0;
      if (threshold<=15) c=calculateCoefficient();
      switch(c){
      case 1: setCeiling(c*2); break;
      case 2: setCeiling(c*3); break;
      else: freakOut();
      }
   }catch(Exception ex){ ... }


Example 4. Good Block Style.


   try {
      int   threshold  = 0;
      float variance    = 0.0;
      int   coefficient = 0;
      
      // Prepare 5 cycles.
      
      for (int i = 0; i < 5; i ++){
         prepareCycle(i);
      }
      
      // Calculate the threshold and variance.
      
      threshold = calculateThreshold();
      variance = (threshold * 2.8) - 1;
      
      // If the threshold is less than the maximum, calculate the coefficient.
      // Otherwise, throw an exception.
      
      if (threshold <= MAX_THRESHOLD) {
         coefficient = calculateCoefficient();
      } else {
         throw new RuntimeException("Threshold exceeded!");
      }
      
      // Set the ceiling based on the coefficient.
      
      switch (coefficient) {
         case 1: 
            setCeiling(coefficient * 2); 
            break;
          
         case 2: 
            setCeiling(coefficient * 3); 
            break;
          
         else: 
            freakOut();
      } // end switch
   } catch(Exception ex) { 
      ... 
   } // end try


Related Links

Tabs vs. Spaces, Jamie Zawinski. 
Writing Robust Java Code — The Ambysoft Inc. Coding Standards for Java, Scott Ambler. 
Draft Java Coding Standard, Doug Lea. 
Java Code Conventions, Sun Microsystems, Inc. 
How to Write Doc Comments for Javadoc, Sun Microsystems, Inc. 
The Jargon File (known in print as The New Hacker's Dictionary), Eric S. Raymond. 
Indent Style, The Jargon File, Eric S. Raymond. 

References

Java Code Conventions. Copyright ) 1995-2000 Sun Microsystems, Inc. 

About the Author
Thornton Rose is a contract software developer in Atlanta, Ga. He can be reached via e-mail at thornton.rose@mindspring.com. 



  

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲一区二区三区四区五区黄| 国产一区二区在线观看免费| 青青草原综合久久大伊人精品优势 | 国产午夜一区二区三区| 一区二区三区中文在线观看| 国产在线播放一区| 欧美一区二区久久久| 亚洲另类春色国产| 成人动漫av在线| 精品久久国产97色综合| 天天色图综合网| 97精品电影院| 国产亚洲一区二区三区在线观看| 三级成人在线视频| 欧美日韩高清一区二区不卡| 亚洲免费色视频| 99re热这里只有精品免费视频| 国产亚洲欧美一级| 九九精品视频在线看| 欧美精品久久天天躁| 亚洲一区视频在线观看视频| 97国产精品videossex| 日本一二三四高清不卡| 国产呦精品一区二区三区网站| 6080国产精品一区二区| 性做久久久久久久免费看| 色94色欧美sute亚洲线路二| 亚洲综合在线电影| 在线视频你懂得一区| 亚洲一区在线视频| 欧美日韩国产不卡| 日韩电影在线观看网站| 欧美一卡二卡在线| 久久精品国产999大香线蕉| 欧美一区二区三区视频在线观看| 午夜精品福利久久久| 91麻豆精品国产91| 美日韩一级片在线观看| 欧美va亚洲va香蕉在线| 久久99精品国产91久久来源| 精品对白一区国产伦| 国产福利精品导航| 亚洲蜜臀av乱码久久精品| 欧美伊人久久大香线蕉综合69| 亚洲大片免费看| 91精品国产乱码| 老鸭窝一区二区久久精品| 久久精品在线免费观看| av网站一区二区三区| 亚洲狠狠丁香婷婷综合久久久| 欧美日韩精品一区二区三区四区 | 日韩三级中文字幕| 精品一区二区免费| 日本一区二区三级电影在线观看| 成人午夜精品在线| 亚洲免费电影在线| 日韩欧美国产小视频| 国产精品91xxx| 亚洲午夜精品在线| 欧美videos大乳护士334| 成人一区二区视频| 图片区小说区区亚洲影院| 精品国一区二区三区| av影院午夜一区| 日韩精品1区2区3区| 国产欧美日韩视频一区二区| 91网站最新网址| 麻豆视频一区二区| 综合色中文字幕| 欧美理论在线播放| 粉嫩高潮美女一区二区三区| 午夜精品在线看| 中文字幕不卡在线| 91精品国产aⅴ一区二区| a级高清视频欧美日韩| 日本亚洲三级在线| 亚洲精品视频在线看| 欧美成人女星排行榜| 一本一道久久a久久精品综合蜜臀| 蜜桃视频在线一区| 一区二区三区国产| 国产精品久久久久婷婷二区次| 欧美性xxxxx极品少妇| 国产精品亚洲视频| 蜜桃av噜噜一区| 亚洲人吸女人奶水| 久久久久久久电影| 日韩一区二区在线观看视频| 一本一道波多野结衣一区二区| 欧美日韩国产成人在线免费| 国产精品一区三区| 免费成人小视频| 亚洲国产美国国产综合一区二区| 国产三级一区二区| 精品国产乱码久久久久久1区2区| 欧美亚洲免费在线一区| fc2成人免费人成在线观看播放| 激情综合五月婷婷| 日韩黄色片在线观看| 亚洲小说欧美激情另类| 亚洲色图在线播放| 国产精品久久久久久福利一牛影视 | 国产在线国偷精品免费看| 日韩高清一区在线| 天天影视涩香欲综合网| 一区二区三区四区在线免费观看| 国产精品色噜噜| 国产三级欧美三级日产三级99| 日韩一区二区三区av| 欧美一区二区三区四区久久| 777精品伊人久久久久大香线蕉| 欧美性色综合网| 欧美日韩精品电影| 欧美日韩国产中文| 日韩一区二区三区在线视频| 91精品久久久久久久91蜜桃| 欧美精品vⅰdeose4hd| 欧美日韩高清不卡| 欧美一区二区日韩| 精品剧情在线观看| 久久久青草青青国产亚洲免观| 久久一区二区视频| 国产三级一区二区三区| 中国色在线观看另类| 国产精品国产自产拍高清av王其| 国产欧美精品区一区二区三区| 国产精品乱人伦一区二区| 国产精品免费久久| 一区二区三区国产精华| 首页国产丝袜综合| 精品无人区卡一卡二卡三乱码免费卡 | 久久嫩草精品久久久久| 美女国产一区二区| 国产一区二区久久| bt欧美亚洲午夜电影天堂| 欧洲av在线精品| 日韩一级欧美一级| 欧美极品aⅴ影院| 一区二区理论电影在线观看| 五月激情丁香一区二区三区| 久久aⅴ国产欧美74aaa| 成人h动漫精品一区二| 欧美吻胸吃奶大尺度电影| 日韩一级免费观看| 亚洲视频一区二区在线| 日韩av中文在线观看| 国产一区二区三区四区在线观看| 波多野结衣亚洲| 7777精品伊人久久久大香线蕉经典版下载 | 青青草国产精品97视觉盛宴 | 国产精品中文字幕日韩精品| 91在线免费看| 日韩一级片在线播放| 18涩涩午夜精品.www| 日韩成人伦理电影在线观看| 丁香六月久久综合狠狠色| 欧美日韩亚洲丝袜制服| 国产欧美一二三区| 日日欢夜夜爽一区| 91尤物视频在线观看| 日韩欧美高清一区| 亚洲视频一区在线| 国产福利91精品| 69av一区二区三区| 亚洲精品免费在线播放| 久久爱另类一区二区小说| 色综合久久综合网97色综合 | 宅男在线国产精品| 国产精品伦一区| 国产揄拍国内精品对白| 欧美区在线观看| 亚洲专区一二三| 成人不卡免费av| 久久久噜噜噜久久人人看| 午夜电影网一区| 色综合 综合色| 国产精品美女久久久久久久久| 精久久久久久久久久久| 欧美一级二级三级乱码| 亚洲一区二区不卡免费| 91亚洲精品久久久蜜桃| 中文字幕av资源一区| 国产一区二区不卡| 日韩欧美国产系列| 日本伊人精品一区二区三区观看方式| 欧美在线不卡视频| 亚洲色图欧美激情| 成人a区在线观看| 国产欧美精品一区二区三区四区| 麻豆国产欧美一区二区三区| 在线综合亚洲欧美在线视频| 亚洲成人1区2区| 欧美三区在线观看| 亚洲欧美区自拍先锋| 一本一道久久a久久精品综合蜜臀| 国产精品久久久久久久蜜臀| 国产成人在线看| 国产精品理论片在线观看| av亚洲产国偷v产偷v自拍| 亚洲人妖av一区二区|