20165301 Chen Tanfei 2017-2018-2 20165325 Experiment 3 "Java Object-Oriented Programming" experimental report

2017-2018-2 20165325 Experiment 3 "Java Object-Oriented Programming" experimental report

1. Agile Development and XP Practice-1

Experimental requirements:
  • Use the tool (Code->Reformate Code) in IDEA to reformat the following code, and then study the Code menu to find a function that makes you feel the best. Submit a screenshot and add your student ID watermark.
public class CodeStandard {
public static void main(String [] args){
StringBuffer buffer = new StringBuffer();
buffer.append('S');
buffer.append("tringBuffer");
System.out.println(buffer.charAt(1));
System.out.println(buffer.capacity());
System.out.println(buffer.indexOf("tring"));
System.out.println("buffer = " + buffer.toString());
if(buffer.capacity()<20)
buffer.append("1234567");
for(int i=0; i<buffer.length();i++)
System.out.println(buffer.charAt(i));
}
}
Experimental screenshot
  • settingClick --- Plugins--- in IDEA Brows Repositories, search alibabbaand download

  • Right-click on the project and select Coding Protocol Scan

  • before formatting

  • after formatting

  • After using code->Reformat alignment

2. Agile development and XP practice-2

Experimental requirements
  • Add your learning partner to your own project on the code cloud. After confirming that the partner's project is added to your own, download the Complex code of partner experiment 2, add no less than three JUnit unit test cases, and git add .; git after the test is successful commit -m "Add content to your student number"; git push; submit a screenshot of the git log of the partner project, including the above git commit information, and add your own student number watermark information.
Experimental screenshot

3. Agile Development and XP Practice-3

Experimental requirements
  • http://www.cnblogs.com/rocedu/p/4795776.html , the content of Eclipse is replaced with IDEA
  • Complete the refactoring exercises, download your partner's code, perform at least three refactorings, submit a screenshot of the refactored code, and add your own student ID watermark. Submit your partner's code cloud project link.
Experiment content and screenshots
  • Refactoring is to change the internal structure of the software to make it easier to read, maintain and change without changing the external behavior of the software.

  • Refactoring method

  • Rebuild shortcuts
  • Rename files, methods, properties, etc. (rename):SHIFT+F6
  • Extract the current selection as a variable:CTRL+ALT+V
  • Extract the current selection as an attribute (extract field):CTRL+ALT+F
  • Extract the current selection as a constant:CTRL+ALT+C
  • Extract the current selection as a method:CTRL+ALT+M
    • Extract the current selection as a method parameter:CTRL+ALT+P
  • Refactoring classes and methods (change signature):CTRL+F6
  • Extract code blocks into if, try, etc. structures (surround with):CTRL+ALT+T
  • Create module files etc (new):CTRL+ALT+N
  • Create a test case (test):CTRL+SHIFT+T
  • Refactor the menu (refactor for this):CTRL+T

  • refactoring process

code before refactoring


public class csj
{
    public static int csj(int n)
    {
        if(n>=0)
            if(n==0||n==1)
                return n;
            else
                return csj(n-2)+csj(n-1);
        return -1;
    }
    public static void main(String args[])
    {

        int m=25,n;
        int fib[]=new int[m];
        for(n=0;n<m;n++)
            fib[n]=csj(n);
        for(n=0;n<fib.length;n++)
            System.out.print(" "+fib[n]);
        System.out.println();
    }
}
  • The code has the following problems:
    • The class name does not conform to the naming rules;
    • Statement structure is not easy to read
  • Experimental screenshot

3. Agile Development and XP Practice-3

Experimental content
Experimental screenshot

Experimental experience and summary

  • After this experiment, I learned to use the alibaba plugin, which can easily standardize my code. And initially mastered the skill of refactoring. However, due to the lack of code understanding ability, it is not easy to find the shortcomings of the program during refactoring, so it is impossible to standardize the code smoothly. This is where we should learn and improve in the future.
step time consuming percentage
demand analysis 20 13.7%
design 30 20.6%
Code 50 34.4%
test 30 20.6%
analysis Summary 15 10.3%

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325012222&siteId=291194637