2017-2018-2 20165228 Experiment 3 "Agile Development and XP Practice" Experiment Report

2017-2018-2 20165228 Experiment 3 "Agile Development and XP Practice" Experiment Report

Related knowledge points

(1) Agile development and XP

  • Expressed through the XP Criterion:
  • Communication: XP believes that communication among project members is the key to project success, and sees communication as the main driver of coordination and cooperation among projects.
  • Simple: XP assumes that the future cannot be reliably predicted, and it is economically unwise to think about it now, so instead of thinking too much about the future, focus on the immediate.
  • Feedback: XP considers the system itself and its code a reliable basis for reporting the progress and status of system development. The feedback of the system development status can be used as a means to determine the system development progress and decide the next development direction of the system.
  • Courage: Represents XP's view that people are the most important aspect of software development. In the development of a software product, people's participation runs through its entire life cycle. It is the courage of people to get rid of difficulties and let the team forget about the local optimum and achieve more important goals. It shows XP's basic trust attitude towards "people make projects succeed".
  • The rationale for a practice's successful use in an XP environment is presented through the principles of XP, including: rapid feedback, assuming simplicity, incremental change, advocated change, and good work.
  • The cornerstone of XP software development is the activities of XP, including: coding, testing, listening, and designing.

    (2) Coding standard

  • Programming standards make code easier to read and understand, and even guarantee fewer bugs in it. Programming standards include: declarative names, clear expressions, straightforward control flow, readable code and comments, and the importance of using certain rules and idioms consistently when pursuing these.
  • A very important part of the code standard is how to name identifiers such as packages, classes, variables, methods, etc. A good name can make your code go up a notch immediately. The general naming rules in Java are:
  • to reflect their meaning
  • nouns for packages, classes, variables
  • method name with verb object
  • The package name is all lowercase, such as: io, awt
  • The first letter of the class name should be capitalized, such as: HelloWorldApp
  • The first letter of the variable name should be lowercase, such as: userName
  • The first letter of the method name should be lowercase: setName
  • The length of the identifier follows the principle of "min-length && max-information"

    (3) Pair programming

  • Pair programming is an important practice in XP. In the pair programming model, a pair of programmers develop work side by side, equally and complementary. They sit side by side at a computer, face the same monitor, use the same keyboard, and work together with the same mouse. They analyze together, design together, write test cases together, code together, do unit testing together, do integration testing together, write documentation together, etc.
  • There are two roles in pair programming:
  • The driver is the person who controls the keyboard input.
  • Navigator (Navigator) plays the role of navigating and reminding.
  • How to pair programming, why pair programming, let's refer to pair programming and cooperation between two people, the key points are:
  • Driver: Write design documentation, do coding and unit testing and other XP development processes.
  • Navigator: Review the driver's documentation, the driver's execution of the development process such as coding; consider the coverage of unit tests; think about whether and how to refactor; help the driver to solve specific technical problems.
  • The pilot and navigator constantly rotate roles, do not work more than an hour continuously, and take a 15-minute break for every hour of work. The navigator has to control the time.
  • Actively participate. Any task is first and foremost the responsibility of two people, but also the responsibility of all. There is no "my code", "your code" or "his/her code", only "our code".
  • There is only a difference in level, there is no difference in level. The two are paired. Although everyone may have different levels of qualifications, both parties have equal decision-making rights in analysis, design or coding.

    version control

    4) Version Control
  • The collective ownership of XP means that everyone is responsible for all the code; this, in turn, means that everyone can change any part of the code. Pair programming contributes a lot to this practice: by working in different pairs, all programmers can see the complete code. A major advantage of collective ownership is the speed at which programs can be developed, since any programmer can fix a bug in the code.
  • This means that the code should be placed in a place where everyone can easily obtain it, we call it a code repository. This leads to another topic called Version Control.

  • Version control provides many benefits, both for teams and individuals.

  • Version control provides project-level undo functionality: nothing is finalized, and any errors must be easily rolled back. Suppose you are using the most complex word processing system in the world. It has all the functions imaginable except that it does not support the DELETE key. Imagine how careful and slow you are when typing, especially when you are nearing the end of a very large document, and you have to start all over again by accident (imagine you select all the text and accidentally press the DELETE key, because There is no undo function, you have to re-enter). Editing text is the same as version control, rollbacks are required at any time, whether it's an hour, a day, or a week, giving your team the freedom to work quickly and confidently to fix bugs.
  • Version control allows multiple people to work on the same code, as long as certain control principles are followed. There will never be a situation where one person overwrites another person's edits, rendering that person's changes invalid.
  • Version control systems keep a history of changes made in the past. If you come across some surprising code, a version control system makes it easy to find out who did it, what was changed, when, and if you're lucky, why.
  • The version control system also supports the simultaneous release of multiple software versions while being developed on the mainline. There is also no need for the entire team to stop work or freeze the code when the software is released.
  • Version control is also a project-level time machine, you can choose any time and see exactly what the project is like at that time. This is useful for research, and is the basis for reproducing a previous release with a problem.
  • git use
  • For the future

    git status

    Check the code status, it shows that there is untracked code, and it is recommended to use

    git add <file>
    Add to
  • If you want to save the code to a remote hosting server, you need to use

    git push

    (5) Refactoring

  • 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.
  • A very key premise in refactoring is "not to change the external behavior of the software", which ensures that we will not bring new bugs to the original system while refactoring the original system, so as to ensure the safety of refactoring. How to ensure that the external behavior of the software is not changed? The refactored code should pass unit tests. How to make it easier to read, easier to maintain and easier to change? Design patterns give goals for refactoring
  • Add new functions;
  • The original function has BUG;
  • Improve the structure of the original program;
  • Optimize the performance of the original system.
  • The simplest Duplicated Code is [two methods in the same class contain the same expression (expression)]. At this time, all you need to do is to use the Extract Method to extract the repeated code, and then let both places call the extracted piece of code.
  • Another common case is [two sibling subclasses contain the same expression]. To avoid this, just use the Extract Method on both classes, and then use the Pull Up Method on the extracted code to push it into the superclass.
  • If the code is only similar, not identical, then the Extract Method must be used to separate the similar part and the difference part to form a single method. Then you may find that you can use the Form Template Method to obtain a Template Method design pattern.
  • If there are methods that do the same thing with different algorithms, you can choose the clearer one and use the Substitute Algorithm to replace the algorithms of the other methods.
  • If Duplicated Code appears in two unrelated classes, you should consider using Extract Class for one of them, extracting the duplicated code into a separate class, and then using the new class in the other class. However, it's also possible that the method where the duplicated code is located should really only belong to one class, and another class can only call it, or - the method could belong to a third class, and the other two classes should refer to this third class. You have to decide where the method is most appropriate and make sure it doesn't appear anywhere else once it's placed.
  • Rename classes, packages, methods, variables

    Rename
  • Normal refactoring can use Extract Method when code duplication issues arise

    Extract Method

    - Specialized tostring() method:

    Generate toString()

    Experimental content

    (1) Agile development and XP practice-1

    Checkpoint requirements:
  • Refer to http://www.cnblogs.com/rocedu/p/6371315.html#SECCODESTANDARD to install the alibaba plugin to solve the specification problem in the code.
  • 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));
    }
    }
    Related screenshots:

    Mouse selection code-->Reformat Code

(2) Agile Development and XP Practice-2

Checkpoint requirements:
  • Add your learning partner to your own project on the code cloud. After confirming that the partner's project is added to yourself, 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 partner project git log, including the above git commit information, and add your own student number watermark information.

    Related screenshots:

    Add addition, subtraction, multiplication and division tests

(3) Agile development and XP practice-3

Checkpoint requirements:
  • Refer to Experiment 3 Agile Development and XP Practice http://www.cnblogs.com/rocedu/p/4795776.html , replace the content of Eclipse 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.

    Related screenshots:
    Identifiers can be modified using Refactor-->`Rename
  • Implemented the replacement of some meaningless variable names and omitted some redundant variables to save memory space.
  • Implement the print content through the extract methodnew private static Stringmethod

(4) Agile Development and XP Practice-4

Checkpoint requirements:

Step time-consuming percentage
Requirement analysis 50 17%
Design 60 20%
Code implementation 120 40%
Testing 40 13%
Analysis and summary 30 10%

Guess you like

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