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

Experiment 3 "Agile Development and XP Practice" Experiment Report

lab report cover

Experimental content

  1. XP Basics

  2. XP Core Practices

  3. Related tools

Experimental procedure

(1) Agile Development and XP Practice-1

Experimental requirements:

Refer to Code Specification to install the alibaba plug-in 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));
}
}
  • Plugins in IDEA, installed through the official Jetbrains repository: Open Settings-> Plugins-> Browse repositories. Enter alibaba in the search box to see the Alibaba Java Code Guidelines plugin, click Install to install it, and then restart IDEA to take effect.

  • Right-click on the project name and select Coding Protocol Scan from the pop-up menu.

  • Formatted code screenshot:

  • I think Code-> Move Line Down/Upworks great, put the cursor anywhere on a line, and by pressing Shift+Alt+PgUp/PgDn, move the line up and down.

Screenshot of the running result before moving:

Screenshot of the running result after moving:

  • Code specification knowledge points

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:

- 要体现各自的含义
- 包、类、变量用名词
- 方法名用动宾
- 包名全部小写,如:io,awt
- 类名第一个字母要大写,如:HelloWorldApp
- 变量名第一个字母要小写,如:userName
- 方法名第一个字母要小写:setName

The name of the identifier should be intuitive and spelling, and the meaning of the text should be understood, and there is no need to "decode". Generally, English words or their combinations are used to facilitate memory and reading. Do not use Chinese pinyin to name them. The words should be accurate, such as "current value". "It should be named currentValue, it's nowValuenot , but it's okay, it dqz's a joke to write it (the initials of dang qian zhi).

“min-length && max-information”The principle of the length of the identifier , such as: maxValbetter maxValueUntilOverflowthan the ratio, you can shorten the variable name by de-vowel method, such as returnValue-> rtnVal, message-> msg; generally global variables use descriptive names, local variables use short names: single character The names, common such as i, j, ketc. are used as local variables.

(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.

  • Add your study partner to your project, 管理-> 项目成员管理->开发者

  • Add JUnit unit test cases

20165306 Add ComplexTest

(3) Agile Development and XP Practice-3

Experimental requirements:

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.

  • Refactoring knowledge points:

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.

A complete refactoring process includes:

- 从版本控制系统代码库中Check out code
- 读懂代码(包括测试代码)
- 发现bad smell
- Refactoring
- 运行所有的Unit Tests
- 往代码库中Check in code
  • Extract MethodExtract the duplicated code, and then have both locations call the extracted piece of code.

  • To avoid two sibling subclasses containing the same expression, just use it on both classes Extract Method, and then use it on the extracted code Pull Up Methodto push it superclassin.

  • If the code is only similar, not exactly the same, then you have to use Extract Methoda method to separate the similar parts from the differences and form a single method. Then you may find that you may be able to apply Form Template Methoda Template Methoddesign pattern.

  • If there are methods that do the same thing with different algorithms, you can choose the clearer one and use Substitute Algorithmthe algorithm to replace the other method.

  • If two unrelated classes appear Duplicaded Code, you should consider using one of them Extract Class, distilling the duplicate code into a separate class, and then using the new class in the other class. However, it is also possible that the method in which the duplicated code is located should indeed belong to only one class, and another class can only call it, or the method may 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.

  • Refactor fenshu

(4) Agile Development and XP Practice-4

Experimental requirements:

Refer to Java Cryptography Algorithms , complete the learning of Java Cryptography related content in pairs, combined with refactoring, git, and code standards. Submit the learning outcome code cloud link and representative results screenshots, with a student ID watermark.

  • Java Symmetric Encryption-DES Algorithm: Generation and Storage of Symmetric Keys

Save in a file in bytes:

  • Java Symmetric Encryption - DES Algorithm: Encrypt and Decrypt with Symmetric Keys

The input is the key stored in the file key1.dat as an object, and the simplest string "Hello World!" that needs to be encrypted. Use the key to encrypt "Hello World!", and the encrypted information is stored in in the file.

  • Java Symmetric Encryption - DES Algorithm: Running the Program

The current directory must have the previously generated key file keykb1.dat and the ciphertext file SEnc.dat. Enter java SDec to run the program, which will output the plaintext string "Hello World!".

demand analysis:

step time consuming percentage
demand analysis 15 minutes 7%
design 100 minutes 48%
Code 35 minutes 17%
test 30 minutes 14%
analysis Summary 30 minutes 14%

Guess you like

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