20172307 2017-2018-2 "Program Design and Data Structure" Experiment 2 Report

20172307 2017-2018-2 "Program Design and Data Structure" Experiment 2 Report

Course: "Program Design and Data Structure"
Class: 1723
Name: Huang Yutang
Student ID: 07
Experiment Teacher: Wang Zhiqiang
Experiment Date: April 18, 2018
Compulsory/Elective: Compulsory

Experimental content

1. Preliminary mastery of unit testing and TDD

2. Understand and master the three elements of object-oriented: encapsulation, inheritance, polymorphism

3. Preliminary grasp of UML modeling

4. Familiarize yourself with SOLID principles

5. Understand Design Patterns

Complete the experiments (1)-(5) on the blue ink cloud.

Experimental process and results

(1). Experiment 1: Practice unit testing, learn to write three types of code (pseudo code, product code, test code), and use Junit to test.
Screenshot of the test case:

Reference ( Intellj IDEA Simple Tutorial )
(2) Experiment 2: Learn the Stringbuffer class in a TDD way and use Junit to test.
Screenshot of test case:

Reference ( actively typing code, using Junit to learn Java programming )
(3) Experiment 3: Expand the design case, and proceed according to the remainder of the student number divided by 6. Experience the OCP, DIP mode.
Screenshot of the expanded code

Reference ( Experiment 2 Java Object-Oriented Programming )
(4) Experiment 4: Develop a Complex class in TDD mode and test it with Junit
Screenshot of the test case:

(5) Experiment 5: Use StarUml to model
Uml diagram:

Reference ( A little explanation of Experiment 2 "Java Object-Oriented Programming" )

Problems encountered during the experiment and the solution process

  • Question 1: The assertEquals statement is not well understood when using Junit. would not use
  • Solution to problem 1: With the help of my partner Zhao Xiaohai, I understood the usage of assertEquals: assertEquals(" ",....) Enter your expected results in the quotation marks in front of assertEquals(" ",....) and the method you want to test in the back. When the result is inconsistent with what you expected, an error will be reported.
  • Question 2: The following error occurred while writing the Complex class
  • Problem 2 Solving Process
    Old problem = is assignment, == is equal. Such low-level mistakes are to be avoided in the future.

    Other (perception, thinking, etc.)

    I felt that my practical ability was not enough for this experiment, so I finished it with the help of my classmates. In the future, try to improve your practical ability.

References

( Intellj IDEA Simple Tutorial )
( Actively type code, use Junit to learn Java programming )
( Experiment 2 Java object-oriented programming )

Guess you like

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