Second Test report of laboratory building

Source: Internet
Author: User

Second Test report of laboratory building

Beijing Institute of Electronic Technology (Besti)

Actual inspection report

Course:Java Programming Class: 1353 Name: Cambridge King:20135316

Score: Instructor: Lou Jia Peng Experimental Date: 2015.5.6

Experiment level: Preview degree: experiment Time:

Instrument Group: Compulsory / elective: Elective experiment number: 2

Experiment Name: JAVA Object-oriented programming

Experimental purposes and requirements:

1. Initial mastery of unit testing and TDD.

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

3. Get a basic understanding of UML modeling .

4. Be familiar with S.O.L.I.D principles.

5. Understand the design pattern.

Experimental instrument:

Name

Model

Number

Pc

Lenovo

1

Virtual machines

Laboratory Building

1

First, the experimental steps

There is a unit test tool JUnit in Java to aid TDD, and we use TDD to rewrite the example of the previous percentile five-point system. , and realize the benefits of development with test tools support.
Open Eclipse, click File->new->java Project to create a new Tdddemo Java project, such as:

Note that the test case must have an annotation @Test before the test case Method name arbitrary, the code is as follows:

After testing, the final result is as follows:

After that, add the test exception and test boundary condition code as follows:

The test run results are entered below:

(ii) Object-oriented three elements

(1) abstract

Abstract the meaning of the word refers to people in the cognitive thinking activities in the object of the appearance of the factors of abandonment and the essence of the extraction of factors. Abstract is a kind of thinking tool that people often use when they know complex things and phenomena, and abstract thinking ability is very important in program design," Refine, Youbiaojili and different " . To a large extent, the abstract ability of the programmer to determine the program design capabilities.
Abstraction is a matter of extracting the essential features of things and not considering their details for the time being. For complex system problems, we can solve problems by means of hierarchical abstraction. At the highest level of abstraction, the solution of the problem is described in a generalized way, using the language of the problem environment. In the lower layers of abstraction, they are described in a procedural way. When describing a problem solution, use a problem-oriented and implementation-oriented terminology.
In program design, abstraction consists of two aspects, one is process abstraction and the other is data abstraction.

(2) encapsulation, inheritance, and polymorphism

Object oriented(object-oriented)the three elements include: encapsulation, inheritance, polymorphism. Object-oriented thinking involves all aspects of software development, such as object-oriented analysis (OOA), Object-oriented design (OOD), object-oriented programming implementation(OOP). OOAaccording to the abstract key problem domain to decompose the system, concernWhat Is ( What)。OODis an object-oriented implementation of the symbolic design system, which is constructed in a way that is very close to the problem domain terminology."Real World"the object of concernWhat to Do ( How),implement functional specifications through the model. OOPbased on the design, use a programming language such asJava) encoding. ThroughOOA,OODand theOOPThe main line is abstract.
OodGraphical Modeling Language for modelingUML(Unified Modeling Language), UMLis a generic modeling language that we use in our experimentsUmbrello is modeled,Windowsrecommended for everyone to use StarUML.

The result of a process abstraction is a function, and the result of the dataabstraction is an abstract data type (abstract datatype,ADT), which can be used as an ADT with inherited and polymorphic mechanisms . data abstraction is the core and origin of OOP.

(iii) Preliminary design pattern (1)S.O.L.I.DPrinciples

object-oriented three elements are " encapsulation, inheritance, polymorphism " S.O.L.I.D class design principle is a good guide:

    • SRP (Single Responsibility Principle, sole responsibility Principle )
    • OCP (open-closed Principle, open - closed principle )
    • LSP (Liskov substitusion Principle,liskov substitution principle )
    • ISP (Interface segregation Principle, interface separation principle )
    • DIP (Dependency inversion Principle, dependency inversion principle )

OCP is one of the most important principles in OOD, andthe OCP's content is:

    • Software entities (class, modules, function, etc) should open for extension,but closed for modification.
    • Software entities (classes, modules, functions, etc.) should be open to expansion and closed to modifications.

The behavior of the software module must be extensible for the open forExtension , we need to make the module work in different ways when the application needs change or need to meet the new application requirements. To modify the enclosing (Closed For modification ) requires that the source code of the module is not modifiable, and no one is allowed to modify the existing module. Based on the OCP, with the object-oriented polymorphism (polymorphic), more flexibility in handling change embrace changes,the OCP can be implemented by: (1) abstraction and inheritance, ( 2 ) interface-oriented programming.

(iv) Practice

1, the use of TDD Design off the implementation of the plural class Complex.

(1) pseudo-code

1, define a complex number class, and use variables to represent the real and imaginary parts of a complex number.

2, Add and subtract the complex number by adding and decreasing the real part and imaginary part of the plural class respectively.

3.print the plural in the plural format

(2) Product Code

(3) test code

Ii. problems encountered and their solutions

1, in this test, basically mastered the TDD test method, due to carelessness, the first experiment when the test code was written to forget the input @test, resulting in the failure of the experimental results, into the repeated view of the teacher code successfully found the error is resolved the problem;

2, in the process of adding abnormal test and test boundary, the final result can not reach the teacher gave the results of the experiment, hints of error, after careful reading of two Java files and error prompts, bold changes to the teacher's code, the results are as follows:

Finally reached the experimental goal of the test pass.

3, the overall experiment, the operation is relatively unfamiliar, after many exercises, to improve a certain degree of proficiency, bold attempt to operate independently, the basic can achieve the basis of the operation results;

Third, the experimental Harvest

After the first use of the experimental building, this experiment has a certain understanding of the experimental building, the operation is relatively not so difficult. Based on the teacher's detailed steps, the results of the experiment can be successfully obtained. In the face of problems, according toEclipsethe error message, know where to go to find errors, after careful review of the code, independent thinking of the problem, bold attempt to modify the code, repeatedly debugging, and finally to achieve the subject of the experimental practice. Through this experiment, I learned TDD.TestMethods as well as the three elements of object-oriented, encapsulation, inheritance, polymorphism and abstraction have a certain understanding and understanding, make up for the knowledge of the blank. Finally, we learned about the solid design principles, the SRP (single Responsibility Principle,single principle of responsibility)OCP (open-closed Principle,Open-Closure Principle) LSP (Liskov substitusion Principle,liskovReplacement Principle) ISP (Interface segregation Principle,Interface Separation Principle) DIP (Dependency inversion Principle,Dependency Inversion principle)。 This experiment has yielded a lot.

Second Test report of laboratory building

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.