Computing and software engineering work 3

Computing and software engineering work 3

Work requirements https://edu.cnblogs.com/campus/jssf/infor_computation17-31/homework/10454
Course targets Complete the development of simple software features, will simply identify and modify the code vulnerability, adaptation can be achieved according to the existing code in order to achieve portfolio of diversified demand
The current work program to achieve my goal in terms of performance Code testing can achieve control of the whole code, the code to ensure reliability. Help me complete the testing and repair of part of the code vulnerabilities
references https://www.cnblogs.com/njzy123456/p/9755642.html https://www.cnblogs.com/wolfrickwang/p/3767306.html https://blog.csdn.net/duoduo18up/article/details/79526659 https://www.cnblogs.com/xinz/archive/2011/11/20/2255830.html https://www.cnblogs.com/SivilTaram/p/software_pretraining_cpp.html
Text of the job https:////www.cnblogs.com/yangqiuyan/p/12434874.html

Pre-class reading stage:

1. The opposite of skill - Cube and imitate
real grasp on the skills, teachers use a very simple example of the Rubik's Cube was a metaphor, really want to master the skills required by constant practice, those low-level problems are solved, do not become after the automatic operation of the brain, and then have the time and brain power to solve high-level problems. In order to truly "different" stand out even more should really grasp the essence of innovation, in practice truly improve the skill levels, not plagiarism standards.
2. modern software engineering - software engineers the ability to self-evaluation form
to enhance its soft power aspects and skills: maintain high standards, not subject to the broken window theory; the initiative to solve the problem; often to recharge your batteries, to learn more practice; do not repeat; eliminate influence among relevant modules; the estimated time spent on assignments, to avoid accidents;
there are a lot of code editor, the one with a very skilled; understanding of common design patterns and know to choose and use.

Homework stages:

A. Code design

1. Requirements Analysis and certain requirements
to obtain the maximum specified array and subarray (with class / function implementation)
needs to return three kinds of information
1). The maximum subarray and
2). Maximum subarray starting subscript
3). Maximum sub-end of the array subscript
2. specific achieve the effect shots (see the code code link cloud and the end of the text given in the Appendix)

3. the results of the analysis
to achieve the above requirements, there are three main algorithms: solving the violence, the running time is n²; divide and conquer strategy, run time was nlogn; greedy algorithm, the running time is n. Obviously greedy algorithm has advantages and greater operational efficiency. To test the function of the above functions, the following part of the unit I tested against the file.

II. Unit testing

1. Test objects and background in
the hierarchy latitude, can be divided into three test
1). Test Unit
2). Integration Test
3) Performance Test
- unit testing (Unit Test) is a test for the function level by developers to write, test a function or multiple functions. Unit testing environment should be easy to set up and run, generally do not depend on other services running: such as databases, caching, and other third-party services, so in other local produce often need to rely on mock framework, so help enhance the development efficiency. Unit testing focused on coverage, usually about 70-80% coverage tend to meet most of the scenes.
· Integration Testing (Integration Test) is a test case for the API level, written by developers / testers, test one or more API function is normal, the co-ordination between multiple components work properly. Integrated test environment to build relatively complex, it may depend on the database, caching, and other third-party services, usually we shared.
· Performance testing (Performance Test) is mainly used to test the performance, analyze performance bottlenecks, etc., it is similar to high-level test. Affected by many conditions, performance testing different ways of application varies, in this little expansion.
· The greater the amount of code of the project, the more test cases need to protect its quality. The greater the amount of code, which means all the more difficult versed in logic, the greater the uncertainty brought about by the impact of each commit. Typically, each commit should merge request can be submitted after the unit testing and integration testing Xianpao pass. Each time you publish on-line, make sure releases through unit testing and integration testing, some applications even require to run through the performance test.
2. Test procedure and requirements
1) Process: At the beginning all the unit tests fail, the improved process to add the correct logic, see through test unit, and see an increase in code coverage repeated until all the unit tests passed, the code coverage Satisfying result.
2) Requirements: class initially empty, are simple return value, for example 0. test includes a test file is read into the calculation.
3. The specific implementation and effects shots (see the code code link cloud and the end of the text given in the Appendix)


4. Results analysis
· simplify the steps: Upon completion of unit testing, unit test project to add a name to UnitTestMain in solution inside the main project UnitTestMain file directory to the directory that contains the project, and then in solution Explorer, right-click UnitTestMain project properties -> VC ++ directory -> directory that contains your changes, and edit unittest1.cpp UnitTestMain project.
· Problem: When running the test cpp file a written test code beginning has been unable to achieve test (header file designated red line), the access to information that you must configure the properties as shown below:

III. Blog jobs

· Review three years of study: Freshman came into contact with simple computer application software (MS Office) and the basic C ++ programming language, learned about the class of functions, classes, streaming and file operations. Of the word, ppt, excel more skilled usage, and the code will be programmed simply bubbling simple algorithm code amount within 50 rows sorting algorithms. Sophomore learning more advanced computer language Java language, will do some simple graphical interface, it can be programmed similar to the C ++ language with java language; further study the data structures course, you can do some relatively complex requirements according to provide code changes implementation, learned the basics of computer data. Junior learning database, operating system, ASP, MATLAB scientific computing courses more specific understanding of the operation of writing computer code. Learning the skills to establish the site, the site will achieve the basic operation to complete more complex similar to online chat rooms, the establishment of the optical disk library loan system. Matlab learning more to meet the needs of mathematical calculations, write some mathematical algorithm will facilitate the statistics and comparison, we will build a database, complete the basic operation of large data background. Understanding of computer algorithms like greedy algorithm, bankers algorithm, hash algorithm classic.
· Future: I want to learn this semester computing and software engineering curriculum in their own learning and teachers can help with simple software development, understand the relatively large software development projects can be completed or real meaning of their cooperation after the software development process . You can learn the basic course of the series he has learned previously and improve the code programming capability, the ability to exercise their own logic and the ability to modify the code vulnerabilities.

IV. Handout preview

(A) code specification
· principles of coding style is: simple, easy to read, unambiguous.
Code specification:
(1) code style specification. Can be improved from the following aspects: indent, line width, brackets, broken line with blank rows {}, branch, name, underlined problems, problems case, the comment (comment complicated function should be placed header)
(2) specification code design. Can be improved from the following aspects: function, GOTO, error processing (parameter processing, asserted), how to handle the C ++ classes
* Key: Processing in C ++ Class
1) Class: using class to encapsulate an object-oriented concepts and multiple state (Polymorphism). To avoid passing a value type of entity, it should pass a pointer. In other words, for simple data types, it is not necessary to achieve a class. For explicit constructor and destructor, do not create a global entity, because you never know when they are created and eliminated. Only when necessary, using only "class."
2) virtual function (Virtual Functions): virtual functions to achieve polymorphism (Polymorphism). Only when necessary, using only virtual functions. If a type to achieve polymorphism, the destructor in the base class (Base Class) should be in the virtual function.
3) Constructors Constructors: Do not do complex operations in the constructor simply initializes all data members can be.
Constructors should not return an error (in fact can not be returned). The possible error operations into HrInit () or FINIT () in.
4) destructor: all cleanup work on the destructor. If some resources before the destructor on the release, remember to reset these members is 0 or NULL. Destructor should not be wrong.
5) type inheritance (Class Inheritance) When necessary, use only the type of inheritance. Const marked read-only parameters (parameter points to the data is read-only, instead of the parameter itself). Const denoted by the function does not change the data.
(B) Code Review
· Objective: To identify the error code; discover logic errors; discovery algorithm error; identify potential errors and regression errors; find possible areas for improvement; education (mutual education) developers, teaching experience, make more many members are familiar with the code of each part of the project, while familiar with practical knowledge and application dependent.
· Steps: Make sure that the code must be compiled successfully, the programmer must have tested the code; the programmer must provide the new code, and file difference analysis tool, in the face of review, in general, is the developer control process, about the causes and effects of modification. But the review is entitled to interrupt the narrative at any time, they put forward their views, one by one reviewer must give feedback; the results of the review, the two sides must reach a consensus.
(C) pair programming
- knot of programming has two roles: the driver (Driver) is to control the keyboard input of people; Navigator (Navigator) play a pilot, a reminder of the role.
· Advantages: 1) the level of development, pair programming can provide better design quality and code quality, and they work to have a stronger ability to solve problems. 2) to developers themselves, the pair work to bring more confidence, high-quality output can lead to higher satisfaction. 3) Psychologically, when there are other people around you and your mate to do the same thing when you deserted embarrassed, embarrassed fool. 4) in the enterprise management level, pair can communicate more effectively, learn from each other and transfer experience, better able to handle the movement of persons. Because a person's knowledge has been shared by other people.
· Methods: assertion, bridges, persuade,
(d) giving advice method
"Impact + Feedback"
For three layers: the outermost layer (behavior and the consequences of) an intermediate layer (habits and motivation) the innermost layer (the essence and basic properties)

V. code hosting

The new hosting just two cpp files submitted directly to the individual warehouse.

Cloud link code:

https://gitee.com/yang_qiu_yan/ruangong

Appendix Code

//maxarray.cpp
#include<iostream>
#include<cstdlib>
using namespace std;
int getmax(int array[],int length)
{
    int sum = 0;    
    int max = 0;   
    int startIndex = 0; //记录子数组的起始位置
    int endIndex = 0;   //记录子数组的终止位置
    int newStartIndex = 0;  
    for (int i = 0; i < length; i++)    //遍历整个目标数组
    {
        if (max < 0)  
        {
            max = array[i];    
            newStartIndex = i;  
        }
        else
        {
            max += array[i];   
        }
        if (sum < max) //如果此时 sum < temp;
        {
            sum = max; 
            startIndex = newStartIndex; 
            endIndex = i;   
        }
    }
    return max;
}

int getstartIndex(int array[],int length)
{
    int sum = 0;    
    int max = 0;   
    int startIndex = 0; 
    int endIndex = 0;   
    int newStartIndex = 0;  
    for (int i = 0; i < length; i++)    
    {
        if (max < 0)   
        {
            max = array[i];    
            newStartIndex = i; 
        }
        else
        {
            max += array[i];   
        }
        if (sum < max) 
        {
            sum = max;
            startIndex = newStartIndex; 
            endIndex = i;   
        }
    }
    return startIndex;
}
int getendIndex(int array[],int length)
{
    int sum = 0;    
    int max = 0;   
    int startIndex = 0;
    int endIndex = 0;   
    int newStartIndex = 0;  
    for (int i = 0; i < length; i++)    
    {
        if (max < 0)  
        {
            max = array[i];    
            newStartIndex = i;  
        }
        else
        {
            max += array[i];   
        }
        if (sum < max) 
        {
            sum = max; 
            startIndex = newStartIndex; 
            endIndex = i;  
        }
    }
    return endIndex;
}


int main()
{
    int array[]={-32,-10,33,-23,32,-12,41,-12,1,3,5,-98,70,-21,10,-9,61};
    int length=17;
    cout<<"Sum of the largest subarray:"<<getmax(array,length)<<endl;
    cout<<"Maximum subarray end superscript(strart):"<<getstartIndex(array,length)<<endl;
    cout<<"Maximum subarray end subscript(end):"<<getendIndex(array,length)<<endl;
    system("pause");
    return 0;
}
//unittest1.cpp
#include "stdafx.h"
#include "CppUnitTest.h"
#include "maxarray.cpp"
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace UnitTest1
{       
    TEST_CLASS(UnitTest1)
    {
    public:
        
        TEST_METHOD(TestMethod1)
        {
            // TODO: 在此输入测试代码
            int a[]={-32,-10,33,-23,32,-12,41,-12,1,3,5,-98,70,-21,10,-9,61};
            Assert::AreEqual(111,getmax(a,17));
        }
        TEST_METHOD(getstartIndex_Test)
        {
            // TODO: 在此输入测试代码
            int a[]={-32,-10,33,-23,32,-12,41,-12,1,3,5,-98,70,-21,10,-9,61};
            Assert::AreEqual(12,getstartIndex(a,17));
        }
        TEST_METHOD(getendIndex_Test)
        {
            // TODO: 在此输入测试代码
            int a[]={-32,-10,33,-23,32,-12,41,-12,1,3,5,-98,70,-21,10,-9,61};
            Assert::AreEqual(16,getendIndex(a,17));
        }
    };
}

Guess you like

Origin www.cnblogs.com/yangqiuyan/p/12434874.html