Beijing Institute of Electronic Technology (BESTI)
Lab Report
Course: Java Programming class: 1351 Name: School Number: 20135117
Score: Instructor: Lou Jia Peng Experimental Date: 2015.5.7
Experiment level: Preview degree: Experiment time: 16:30-18:30
Instrument Group: Compulsory / elective: Elective experiment number: 2
Experiment Name: Java Object-oriented programming
Experimental purposes and requirements: 1. No Linux The basic students recommend that you first learn the Linux Basic Primer (New edition) " Vim Editor Course
2. Complete the experiment, write the experiment Report, the experiment report is published in the blog Garden, note that the experiment report focuses on the running results, the problems encountered ( tool find, installation, use, program editing, debugging, running, etc. ), Solutions (empty methods such as " Check the network "," ask classmates "," Reading " and so on. 0 and analysis (what can be learned from it, what gains, lessons, etc.)
3. Plagiarism is strictly forbidden, and the results of the experiment of the perpetrator are zero, and other punitive measures are added.
4. Please first in the laboratory building in the ~/code directory with their own school number to create a directory, code and UML diagram to put in this directory, no study number will be required to redo , and then follow the following steps to practice.
Experimental instrument:
|
Name |
Model |
Number |
|
Pc |
Macbookair |
1 |
First, the contents of the experiment
1. Initial mastery of unit testing and TDD
2. Understanding and mastering the object-oriented three elements: encapsulation, inheritance, polymorphism
3. Initial mastery of UML Modeling
4. Familiarity with s.o.l.i.d principles
5. Understanding Design Patterns
Second, the experimental steps
(a) Unit testing
1. Three kinds of code: pseudo-code, product code, test code
(1) Test normal condition
(2) Test error condition
(3) test boundary conditions
2. TDD (Test Driven Development, driver test development )
TDD General Steps
- Clear the current functionality to be completed and record it as a test list
- Quick completion of writing test cases for this feature
- Test code compilation does not pass (no product code)
- Write the Product Code
- Test Pass
- Refactor the code and ensure the test passes (refactoring the next lab session)
- Cycle through the development of all functions
(1)JUnit appears red bar, test failed
(2) After the change appears green bar, test pass
TDD coded Rhythm:
1. add test code,JUnit appears red bar
2. Modify the Product code
3.JUnit appears green bar, task completed
(3) self-test
(ii) Object-oriented three elements
1. Abstraction
2. Encapsulation, inheritance, and polymorphism
Encapsulation actually uses methods to hide the data of the class, controlling the user's modification of the class and the degree to which the data is accessed , thus bringing modularity (modularity) and information hiding (information hiding) the benefits of; Interface ( Interface ) is an accurate description of the package.
- + indicates public
- #表示 protected
- -Indicates private
(iii) Preliminary design pattern
1.S.O.L.I.D Principles
(1)
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 )
(2)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.
(3) The OCP can be implemented in the following ways
Abstract and inheritance B. interface-oriented programming.
(4) The SRP content is:
There should never be + than one reason for a class to change
Never have more than one reason to modify a class
(5) The LSP content is:
Subtypes must is substitutable for their base types
Functions that use pointers or references to base classes must is able to use objects of derived classes without knowing I T
The subclass must be able to be used by its base class
Using a pointer to a base class or a referenced function, you must be able to use it without knowing the specific derived class object type
(6) The content of the ISP is:
Clients should not being forced to depend upon interfaces the They do
Customers should not rely on interfaces that they do not use
(7) The content of the dip is:
The modules should not depend upon low level modules. Both should depend upon abstractions
Abstractions should not depend upon details. Details should depend upon abstractions
High-level modules should not be dependent on low-layer modules. Both should be dependent on the abstract
Abstraction should not depend on detail. Details should depend on abstraction
2. Mode and design mode
GRASP Mode
Analysis mode
Software Architecture Patterns
Design Patterns: Created, structured, behavioral
Management mode: The manager Pool Implementation mode
Interface Design Interaction Mode
...
3. Design Pattern Instances
There are four basic elements of the design pattern:
Pattern name: Description mode, easy to communicate, archive
Problem: Describes where to apply the pattern
Solution: Describes a design's constituent elements, not for special cases
Consequence: The results and tradeoffs of applying this pattern (trade-offs)
(iv) Practice
1. design and implement the plural class Complex using TDD method
(1) pseudo-code
(2) Product Code and test code
2.PSP Time
|
Steps |
Take |
Percentage |
|
Demand analysis |
24min |
20% |
|
Design |
36min |
30% |
|
Code implementation |
24min |
20% |
|
Test |
12min |
10% |
|
Analysis Summary |
24min |
20% |
Iii. Summary
1. Experimental Experience
The main content of this experiment is object-oriented program design, code design, testing methods, really let us program only the last content. The experiment in the design of the time spent significantly more than the last experiment, I found that the design process is very important, if you write some pseudo-code before each programming, there is a clear idea, writing programs will be much faster. The test time of this experiment is similar to that of last time, but I think we should increase the time of testing in the future, and use some of the program's unwanted parameters to test the program better to optimize the program. Through this experiment, I initially understand the JAVA program design and test the importance of the future must continue to strengthen training.
2. Benefits of Unit testing
Reduce problem occurrence and improve program quality
Faster positioning of problems in which module, increase efficiency, reduce costs
The design of the optimization program
You can safely modify some of the code
Java Experiment II