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

Course: "Program Design and Data Structure"
Class: 1723
Name: Wang Yuhan
Student ID: 20172323
Experiment Teacher: Wang Zhiqiang
Experiment Date: April 22, 2018
Compulsory/Elective: Compulsory

Experimental content

  1. Getting started with unit testing and TDD

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

  3. Preliminary mastery of UML modeling

  4. Become familiar with SOLID principles

  5. Learn about design patterns

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

Experimental process and results

Experiment 1

  • Completion of unit testing is required and use of JUnit test cases (normal cases, error cases, edge cases)
  • The experimental results are shown in the figure:

Experiment 2

  • Study and learn StringBuffer in the way of TDD, and learn to write JUnit test cases by yourself
  • The experimental results are shown in the figure:

Experiment 3

  • Expand the design pattern examples, realize the application of OCP principles and DIP principles, and have a preliminary understanding of design patterns
  • The experimental results are shown in the figure:

Experiment 4

  • Develop a complex class Complex in a TDD manner
  • There was an error in submitting the screenshot in this experiment, and now resubmit
  • The experimental results are shown in the figure:

Experiment 5

  • Modeling the code in the experiment using StarUML
  • The experimental results are shown in the figure:

Problems encountered during the experiment and the solution process

Problem 1: Not particularly understandable about SOLID principles
Problem 1 solution:

  • SRP (Single Responsibility Principle, single responsibility principle)
  • OCP (Open-Closed Principle, Open-Closed Principle)
  • LSP (Liskov Substitution Principle, Liskov Substitution Principle)
  • ISP (Interface Segregation Principle)
  • DIP (Dependency Inversion Principle, Dependency Inversion Principle)

Through this blog , I generally have some perceptual understanding of the concept.
  • SRP: Refers to a class that only completes the responsibilities it should complete,
  • OCP: Open for extension, closed for modification.
  • LSP: Inheritance can only be used if it is determined to be an is-a relationship
  • ISP: An interface or class should have as few behaviors as possible
  • DIP: This one doesn't get to the point
  • Other (perception, thinking, etc.)

    This experiment is mainly done step by step according to the tutorial. In fact, it is not as difficult as imagined, and there are no major problems in the process of painting the scoop, but this experiment can actually learn a lot. thing.

    References

    Java Programming and Data Structure Tutorial (Second Edition)

    "Java Programming and Data Structure Tutorial (Second Edition)" study guide

    Guess you like

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