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

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

Course: "Programming and Data Structures"

Class: 1723

Name: Jiang Zixing

Student ID: 20172317

Experimental teacher: Wang Zhiqiang

Experiment Date: April 22, 2018

Compulsory/Elective: Compulsory

Experiment content

  1. Master the basic of unit testing and TDD(Test-driven development)

  2. Understand and master 3 vital elements of object-oriented programming:encapsulation, inheritence, polymorphism

  3. Learn the basis of UML modeling

  4. Acquainted with SOLID principles(SRP, OCP, LSP, ISP, DIP)

  5. Acknowlegde the design pattern

  6. Complete experiment 1-5 from mosoteach

Procedure and the results of the experiments

Experiment 1

Experiment 2 Experiment 2

  • Refer to "Actively type code, use JUnit to learn Java ( http://www.cnblogs.com/rocedu/p/4837092.html )" to further study StringBufferwith TDD method
  • Submit your unit test example and the test passed screenshot
  • Screenshot of the result:

Experiment 3

  • Refer to " Experiment 2 Java Object-Oriented Programming " to expand the exmaples of "design pattern". Experience the application of OCP principle and DIP principle.Understand the "design pattern" preliminarily.
  • Use your student ID to do a remainder calculation, expand the code according to different results:
  • Screenshots of the result(there was some flaws in the original screenshot, the screenshots here are the original screenshot with error and the screenshot of correct output)

    As you can see in the first screenshot, class Double is supposed to print a float, however an integer replaced it.This is because variable value is set to be an int rather than a double

Experiment 4

  • Develop a complex number class Complex in TDD method
  • Screenshot of the result:

Experiment 5

  • Model the code of this whole experiment with StarUML
  • There should be at least 2 classes in the illustration
  • Screenshot of the result:

Problems encountered while experimenting and solutions

  • Problem 1:JUnit? Unit testing? Test-driven development?
  • Solutions of problem 1:Yep, this is it, anotherbullshit experiment, this is really crazy.This time there are thousands of new concepts and things like that, so I have to find informations about these new things.
    Now the first one is JUnit. At first I thought it might be some kind of third party plugin. Well, actually it is ok to say so, but it is a unit testing framework for Java. According to the internet, JUnit plays an important role in the development of test-driven development. By utilizing JUnit, we can write test code, which can greatly improve our coding efficiency.(Though I don't really think so)
    Well.....so, unit testing? The heck is that?According to the internet: "in computer programming, unit testing is a software testing method by which individual units of source code, sets of one or more computer program modules together with associated control data, usage procedures, and operating procedures, are tested to determine whether they are fit for use." Lets explain this in a intuitive way: imagine a factory that assembles tv, each time before a tv is made, it's component would be tested, and that process of testing is the so-called "unit-testing".
    Annnd, "test-driven development", which is also known as TDD, is our next object. Test-driven development (TDD) is a software development process that relies on the repetition of a very short development cycle: requirements are turned into very specific test cases, then the software is improved to pass the new tests, only. This is opposed to software development that allows software to be added that is not proven to meet requirements.

  • Problem 2:SOLID?
  • Solutions of problem 2:SOLID is an acronym for five design principles.The five principles are:SRP(single responsibility principle), OCP(open/closed principle), LSP(Liskov substitution principle), ISP(interface segregation principle), DIP(dependency inversion principle).

Other

As if life isn't suck already, we have to complete all these nonsense in IDEA? NO, it could be worse, that could be worse.
I don't think I learned anything from this experiment, I just do what they told me to do. What a waste of time....
Luckily, it is not a completely meaningless experience. It triggered my thinking on the nature of software development. Here is a question: What can you really do? Are you creating code, or you're just writing code. Although I just hate these stuff, they play a vital rule in the process of software design. I am not good at all of these, but my rusty brain can still learn a thing or two, it's won't cause any loss anyway.

References

SOLID
TDD
Unit testing

Guess you like

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