20165301 Chen Yu Fly 2017-2018-2 20165325 Experiment Report of Java object-oriented programming

Source: Internet
Author: User
Tags naming convention stringbuffer

2017-2018-2 20165325 Experiment Report of Java object-oriented programming

First, agile development and XP practice-1 Experimental requirements:
    • Use the tool (Code->reformate code) in idea to reformat the code below, and then look at the Code menu to find a feature that feels best for you. Submit, plus your own study number 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));}}
Experiment
    • Click setting ------in idea Plugins Brows Repositories to search for alibabba and download

    • Right-click on the project to select the encoding protocol scan

    • Before formatting

    • After formatting

    • After using Code->reformat to align

Second, agile development and XP practice-2 experimental requirements
    • Add your own learning partner to your project in the code cloud, confirm that your partner's project is on your own, download the complex code for your partner experiment two, add not less than three JUnit unit test cases, and then git add after the test is successful. Git commit-m "Add content by yourself"; git push; submit a partner project git log, which contains information about git commit above, plus its own watermark information.
Experiment

Three, agile development and XP practice-3 experimental requirements
    • http://www.cnblogs.com/rocedu/p/4795776.html, eclipse content replaced with idea
    • Complete the refactoring exercise, download your partner's code, make at least three refactoring, commit the refactoring code, and add your own number watermark. Submit a link to your partner's code cloud project.
Experimental content and
    • Refactoring (Refactor)is to change the structure within the software without changing the external behavior of the software, making it easier to read, easy to maintain, and easy to change.

    • Refactoring method

    • Rebuilding shortcut keys
    • Rename files, methods, properties, and so on (rename):SHIFT+F6
    • Extract the current selection as a variable (extract variable):CTRL+ALT+V
    • Extract the current selection as an attribute (extract field):CTRL+ALT+F
    • Extract the current selection as a constant (extract constant):CTRL+ALT+C
    • Extract the current selection as a method (extract):CTRL+ALT+M
      • Extract the current selection as a method parameter (extract parameter):CTRL+ALT+P
    • Refactoring classes, methods (change signarture):CTRL+F6
    • Extract the code block into the IF, try, and other structures (surround with):CTRL+ALT+T
    • Create a module file, etc. (new):CTRL+ALT+N
    • To create a test case:CTRL+SHIFT+T
    • Refactoring menu (Refactor for this):CTRL+T

    • Refactoring process

Pre-refactoring Code

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 match the naming convention;
      • Sentence structure is not easy to read
    • Experiment

Three, agile development and XP practice-3 experimental content
    • Refer to Http://www.cnblogs.com/rocedu/p/6683948.html to complete the learning of Java cryptography related content in pairs, combining refactoring, git, and code standards. Submit the learning Result Code cloud link and the representative result, must have the student number watermark.
Experiment

Experience and summary of experiment
    • After this experiment I learned the use of Alibaba plug-ins, can be very convenient to standardize my code. And initially mastered the ability to reconstruct it. However, due to the lack of code understanding, in refactoring it is not easy to find the program is not enough to be able to standardize the code smoothly, this is in the future should learn the progress of the place.
Steps Time Consuming percentage
Demand analysis 20 13.7%
Design 30 20.6%
Code implementation 50 34.4%
Test 30 20.6%
Analysis Summary 15 10.3%

20165301 Chen Yu Fly 2017-2018-2 20165325 Experiment Report of Java object-oriented programming

Related Article

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.