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

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

lab report cover

    北京电子科技学院(BESTI)
    实     验    报     告
课程:Java程序设计 班级:1652      姓名:陈思兵   学号:20165209
成绩:             指导教师:娄嘉鹏     实验日期:2018年4月28日
实验密级:         预习程度:          实验时间:13:45 - 3:25 
仪器组次:          必修/选修:必修  实验序号:实验三
实验名称: 敏捷开发与XP实践
实验目的:     
1. 初步解决代码中的规范问题
2. 使用单元测试
3. 掌握重构的意义
4. 完成Java密码学相关内容的学习
实验与要求:
1.没有Linux基础的同学建议先学习《Linux基础入门(新版)》《Vim编辑器》 课程
2.完成实验、撰写实验报告,实验报告以博客方式发表在博客园,注意实验报告重点是运行结果,遇到的问题(工具查找,安装,使用,程序的编辑,调试,运行等)、解决办法(空洞的方法如“查网络”、“问同学”、“看书”等一律得0分)以及分析(从中可以得到什么启示,有什么收获,教训等)。报告可以参考范飞龙老师的指导
3.严禁抄袭。

Experiment content and steps

(1) Install the alibaba plug-in to solve the specification problem in the code. Use the tool (Code->Reformate Code) in IDEA to format the code, study the Code menu, and compare the functions.

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.

  • The general naming rules in Java are:
    1. To reflect their respective meanings
    2. Use nouns for packages, classes and variables
    3. Use verb objects for method names
    4. Package names are all lowercase, such as: io, awt
    5. Class names are first Each letter should be capitalized, such as: HelloWorldApp
    6. The first letter of the variable name should be lowercase, such as: userName
    7. The first letter of the method name should be lowercase: setName

(2) Add your learning partner to your own project on the code cloud. After confirming that the partner's project has been added to your own, download the Complex code of partner experiment 2, and add no less than three JUnit unit test cases.

  • 管理Click ---> 项目管理者---> in the corresponding project of the code cloud to 开发者add a partner.

  • unit test

  • Partner project git log

(3) Download your partner's code and complete the refactoring exercise.

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.

(4) Combine refactoring, git, and code standards to complete the learning of Java cryptography related content in pairs.

  • Design Enc_RSA (encryption)

(1) Get the public key

(2) To obtain the parameters (e, n) of the public key, because the key is very long, the corresponding integer value is very large and cannot be stored in a general integer. The BigInteger class is defined in Java to store such large integers. Integers can perform various operations.

(3) Get the plaintext integer (m), the plaintext is a string, in order to express the string as an integer, first use the getBytes( ) method of the string to convert it into an array of byte type, and use the BigInteger class to convert the binary string to Integer.

(4) Execute the calculation

  • Design Dec_RSA (decryption)

(1) Read the ciphertext. Since this line of strings represents a large integer number, the BigInteger class is used to represent this integer number.

(2) To obtain the private key, since the RSA algorithm is used, the public key object is read from the file and forced to be converted to the RSAPrivateKey type, so that the parameters required by the RSA algorithm can be read later.

(3) Parameters (d, n) to obtain the private key

(4) Execute the calculation

(5) Calculate the string corresponding to the plaintext integer number. The result m decrypted by the RSA algorithm is a large integer. In order to calculate the value of the corresponding string, first use the toByteArray( ) method of the BigInteger class to get the representation of the integer. A byte array of type number, and then convert each element in the array to a character to form a string.

  • Design Skey_RSA (create public and private keys)

(1) Read your own private key and the other party's public key, and obtain the key from the file.

(2) Create a key agreement object

(3) Initialize the key agreement object

(4) Execute key agreement

(5) Generate shared information

step time consuming percentage
demand analysis 30min 17%
design 25min 14%
Code 90min 50%
test 20min 11%
analysis Summary 15min 8%

Guess you like

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