20165216 Experiment 2 Java Object-Oriented Programming

2017-2018-2 20165216 Experiment 2 "Java Object-Oriented Programming" experimental report

1: Experiment content and requirements

1: Master the content of unit testing and TDD.

2: Use JUnit to learn Java and TDD to learn StringBuffer.

3: Understand the OCP principle and the DIP principle, let the system support the Float class, and add it correctly in the MyDoc class.

4: Develop a complex class Complex in a TDD manner.

5: Use WhiteStarUML to model the code in Experiment 2.

    : Screenshot with student number watermark

Two: Concept essentials

1: Distinguish three kinds of codes: pseudo code, test code, product code

Pseudo code: The code language has nothing to do with the syntax of the specific programming language. It solves the problem from the intent layer and is a natural annotation of the product code. E.g:

 

Product Code: Code that is directly executed on a computer in assembly or high-level languages.

Test code: In order to maintain the integrity and security of the product code. For a code that is tested by the product code, it should be noted that the test code is generally longer than the product code. Which involves three boundaries of data testing.

TDD (Test Driven Devlopment, Test Driven Development)

To ensure the efficiency of the product code, it is better to use the TDD method for programming, that is, to write the test code first, and then write the product code. (Pseudocode still takes precedence). Proceed as follows:

  • Identify the current functions to be completed and record them as a test list
  • Quickly complete writing test cases for this feature
  • The test code compilation fails (there is no product code)
  • Write product code
  • Test passed
  • Refactor the code and make sure the tests pass (refactoring the next lab exercise)
  • Cycle through the development of all functions  

Proactively code with JUnit

Use the test class to familiarize yourself with the operation of related classes, continuously verify, and actively learn to acquire knowledge.

2: Demonstration of experimental content

Score Normal Test Boundary Test Abnormal Test (for this content it's about score)

Learning StringBuffer by TDD

Application of OCP principles and DIP principles

About system support for Float class, add test code in MyDoc

TDD method to develop complex class Complex

UML modeling

Code cloud link: https://gitee.com/bdace/20165216_chen_houkang.git

 

Guess you like

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