How to Review your own code and review code

Source: Internet
Author: User

How to Review your own code and review code

The reason for writing this blog post is that the code you write is often reworked and the delivery date of the delay project. The reasons for project delay are summarized as follows:

The first step and the second step usually appear at the same time. The second step also appears largely because it does not have an understanding of the requirements interaction details, therefore, the habit we developed during development should be as follows:

Of course, the above summary is still a theory. We should take this as a guide in development to gradually develop good development habits. Annotation usage. When developing a function with someone else, it is very likely that a duplicate method is written due to the name of the method. During code Review, you can add @ Deprecated annotation to the method, indicates that the method is out of date. If an application calls this method, an error is returned.

1 <! -- Annotation example --> 2 3 public class AnnotationTest extends Test 4 {5 6 @ SuppressWarnings ("deprecation") 7 public static void main (String [] args) 8 {9 10 <! -- This is a program command. The operation is to run garbage collection at the end of the program --> 11 System. runFinalizersOnExit (true); 12 sayHello (); 13 AnnotationTest t = new AnnotationTest (); 14 t. show (); 15} 16 17 <! -- If you use this method, an error is returned when you use this method --> 18 @ Deprecated 19 public static void sayHello () 20 {21 System. out. println ("hello, world! "); 22} 23 24 @ Override25 public void show () 26 {27 System. out. println ("super class"); 28} 29 30} 31 32 33 public class Test {34 @ Deprecated35 public void show () 36 {37 System. out. println ("super class"); 38} 39}

 

The preceding example uses the annotation @ Deprecated, @ SupressWarning, and @ Overrider. The annotation is recognized by javac and parsedAnnotation classThe compiler will compile different results based on different annotations. @ Deprecated annotation indicates outdated methods, which will appear when using methods in lower JDK versions; @ SurpressWarning ("deprecation") annotation is used to suppress warnings of obsolete APIs. This can be placed before calling the method of outdated APIS is external or called. Therefore, javac encounters this identifier during compilation, even if you know that the API is outdated, you will not be prompted about the outdated API.

1 <! -- Usage Frequency: 80% --> 2 Alt + '/' code prompts 3 sysout + Alt + '/' to automatically complete "System. out. println (); "4 public void AnnotationTest double-click class name Annotation, click Run As-> Java Application, you can run the test Class 5 Ctrl + '/' to add the comment "//" to the row where the cursor is located. You do not need to select this row in advance, to cancel a comment, you must also press Ctrl + '/'6 Ctrl + Shift +'/'to add a comment "/**/". Select this line in advance, uncomment: use Ctrl + Shift + '\ '7 Ctrl + Shift + 'C' to add multi-line comments "//", cancel the annotation and use Ctrl + Shift + 'C' 8 Ctrl + 'd to delete the current row 9 Ctrl + 'M' to maximize and minimize the current cursor's IDE window 10 Ctrl + 'l 'jump to the specified row number of input 11 Ctrl + Shift + 'T' look for the specified class name in the workspace 12 Ctrl + Shift + 'O' with caution, because sometimes the imported package is not the required package 13 Alt + '<-' and Alt + '->', it tracks the previous position of the cursor and the next position 14 15 Alt + Shift + 'J' add comments, this annotation facilitates Eclipse to generate API documentation,

Appendix:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.