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

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

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

1. Experiment content

1: Preliminary mastery of unit testing and TDD
2: Understand and master the three elements of object-oriented: encapsulation, inheritance, and polymorphism
3: Preliminary mastery of UML modeling
4: Familiar with SOLID principles
5: Understand design patterns
6: Complete the blue ink cloud (1 )-(5) experiment.

2. Experimental process and results

Experiment 1: Practice unit testing, learn to write three kinds of code (pseudo code, production code, test code), and test it through Junit.

When doing experiment one, because everything was done step by step according to the book, there were not too many problems.
Test case screenshot:

Experiment 2: Learn the Stringbuffer class in a TDD way and use Junit to test.

The reference materials for the second step of the experiment are also included, so the problem is not too big. The final result is correct.
Test case screenshot:

  • code link

  • Reference: Actively type code, use JUnit to learn Java ( http://www.cnblogs.com/rocedu/p/4837092.html )

    Experiment 3: Expand the design use case, according to the remainder of the student number divided by 6. Experience the OCP, DIP mode.

    There were a lot of problems when I was doing experiment 3, because when I first started reading the questions, I thought I needed to write six classes, so I wrote all the classes, and then when submitting, it was required that classes such as Double do not It should output an integer number, but I am outputting an integer number.
    Test case screenshot:






  • code link

Experiment 4: Develop a Complex class in TDD mode and test it with Junit

It took a lot of time to do this because I didn't know how to calculate it. Later, I initialized and constructed a complex number, then determined its real and imaginary parts, and then calculated addition, subtraction, multiplication and division by the following methods:

    Complex ComplexAdd(Complex c){//复数相加
        double a = c.getA();
        double b = c.getB();
        double newA = a + this.a;
        double newB = b + this.b;
        Complex Result = new Complex(newA,newB);
        return Result;
    }

    Complex ComplexMinus(Complex c){//复数相减
        double a = c.getA();
        double b = c.getB();
        double newA = a - this.a;
        double newB = b - this.b;
        Complex Result = new Complex(newA,newB);
        return Result;
    }

    Complex ComplexMulti(Complex c){//复数相乘
        double a = c.getA();
        double b = c.getB();
        double newA = a * this.a;
        double newB = b * this.b;
        Complex Result = new Complex(newA,newB);
        return Result;
    }

    Complex ComplexDiv(Complex c){//复数相除
        double a = c.getA();
        double b = c.getB();
        double newA = a / this.a;
        double newB = b / this.b;
        Complex Result = new Complex(newA,newB);
        return Result;
    }   

Test case screenshot:

Experiment 5: Modeling with StarUml

Because I downloaded the black version when I downloaded it, it's not the same as others. When I first started, I couldn't understand the English, and then I slowly groped and made a rough outline.
Uml diagram:

3. Problems encountered during the experiment and the solution process

Question 1: First of all, when uploading, when I uploaded the content I made in the idea with a virtual machine, an error occurred, causing my git file to go wrong
. Problem 1 Solution: After trying many methods to no avail, I had to directly copy the original File backup deleted, then recreated a project, and re-uploaded everything.

Question 2: Because I haven't used idea very much, I often create too many test classes, and I don't know how to solve the
problem. Solution: After reading the reference materials and asking my classmates, I gradually learned Ait+Enter The shortcut keys and the method of processing files will be used gradually, but there are still many problems if you are not skilled enough, so you still need to practice more.

Other (perception, thinking, etc.)

This experiment has a further understanding of the use of ideas. After learning about TDD, SOLID, OCP, DIP and other knowledge, there are still many shortcomings and need to continue to work hard.

References

Guess you like

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