Workers fourth soft - pair programming

course <Software Engineering Fundamentals>
Work requirements <Fourth software engineering jobs - Pair Programming>
github address https://github.com/xxxy7280/WordCount
Partner blog address <Blog address>

PSP table

PSP2.1 Personal Software Process Stages Estimated time consuming (minutes The actual time-consuming (minutes)
Planning plan 30 30
Estimate Estimate how long this task 3 days 5 days
Development Develop 60 80
Analysis Needs analysis (including learning new technologies) 30 45
Design Spec Generate design documents 60 80
Design Review Design review (and colleagues reviewed the design documents) 30 35
Coding Standard Code specifications (development of appropriate norms for the current development) 10 15
Design Specific design 30 30
Coding Specific coding 600 720
Code Review Code Review 60 80
Test Test (self-test, modify the code, submit modifications) 120 130
Reporting report 30 40
Test Report testing report 30 50
Size Measurement Computing workload 20 30
Postmortem & Process Improvement Plan Later summarized, and process improvement plan 60 55
total 1170 1420

Calculation module interface design and implementation

Computing Design

Mind Mapping

addition to the main function, this program is designed in six basic modules,
Characres (): Character achieve statistical
Word_s (): Counting words
Line (): statistics the number of rows
All (): the realization of all output functions
Output (string path) : output to the specified file, specify the file name as a parameter

void  Cal::Output(string path)//输出到文件
{
    ofstream fout;
    string path_1="D:\\wordCount\\201831061307\\Count\\"+path;
    fout.open(path_1);
    //fout.open("D:\\wordCount\\201831061307\\Count\\output.txt");
    fout << "characters:  " << Characters() << endl;
    fout << "words:  " <<Word_s() << endl;
    fout << "lines:  " << Lines() << endl;
    for (int i = 0; i < numofwords - 1; i++)
    {
        fout <<  Words[i].str<< "\t";
        fout << Words[i].many << endl;
    }
    fout.close();
    cout << "成功写入文件"<<endl;
}

cmd enter D: \ WordCount \ 201831061307 \ Count \ Debug \ Count.exe -o output.txt
operating results

Key function - a function of word frequency statistics as follows thinking

Design of the interface package and

Function package

interface

#include"Count.h"

operation result

Code review process

Code Specification:
1, during the variable names and function names defined with the necessary time of annotation for its role and function
2, the function code, add a description where necessary, to facilitate the understanding troubleshooting
3, the global variables must be defined at the beginning, easy to know when to use their sense of
4, when using the tab key to indent (sometimes needs its own indentation)
5, it is necessary to use parentheses, label priority
6, to give variable assignment, a variable line
7, the same variable again when significant, added at the end thereof for distinguishing the digital
reference URL: C language code specification (programming specification) ( http://c.biancheng.net/view/158.html )
two each in the trial problems found:
students a:
sometimes do not explain the significance of the definition of variables 1.
2. the key is not to illustrate the function of the companion dyslexia
3. sometimes forget to indent the code unsightly
students B:
1. multi-defined a number of variables, not used nor delete
does not explain its function 2. write a function

Performance calculation module interface section Improvement

Efficiency Analysis Code - main function

int main()
{
    
    while(1) 
    {
        words();
        sort();
        shuchu(5);
        errno_t  err;
        err = fopen_s(&fp, "D:\\WordCount\\201831061307\\Count\\input.txt", "r+");
        Characters();
        Word_s();
        Lines();
        All();
        Output();
        fclose(fp);
        
    }
    return 0;
}

The initial version of the performance analysis results


The figure shows, the largest is time consuming All () function

void All()//输出所有功能结果
{
    cout << "characters: " << Characters() << endl;
    cout << "words: " << Word_s() << endl;
    cout << "lines: " << Lines() << endl;
    for (int i = 0; i < numofwords - 1; i++)
    {
        cout << Words[i].str << "\t";
        cout << Words[i].many << endl;
    }
}

Display module calculating unit test

Testing the number of words

At this time, add the following code to the Word_s

errno_t  err;
err = fopen_s(&fp, "D:\\WordCount\\201831061307\\Count\\input.txt", "r+");

Test code:

#include "stdafx.h"
#include "CppUnitTest.h"
#include"D:\WordCount\201831061307\Count\Count\Count.h"
using namespace Microsoft::VisualStudio::CppUnitTestFramework;

namespace CountUnitTest1
{       
    TEST_CLASS(UnitTest1)
    {

    public:
        TEST_METHOD(TestMethod1)
        {
            Cal x;
            int count = 107;
            Assert::AreEqual(x.Word_s(),count);// TODO: 在此输入测试代码
        }

    };
}

Test Results:

Testing the number of rows

TEST_METHOD(TestMethod3)
        {
            Cal x;
            int count = 5;
            Assert::AreEqual(x.Lines(), count);// TODO: 在此输入测试代码
        }

If there are empty lines are ignored

Testing the number of characters

TEST_METHOD(TestMethod2)
        {
            Cal x;
            int count = 505;
            Assert::AreEqual(x.Characters(), count);// TODO: 在此输入测试代码
        }

Test Results

Calculating portion exception handling module described

Exception handling function directly in the main window and cmd

Failed to open the specified file

Withdraw from the process to modify the code in a file called a non-existent file open failed to open as read-only

else if(...)
{
   errno_t  err;
        err = fopen_s(&fp, "D:\\WordCount\\201831061307\\Count\\eee.txt", "r+");
        if (fp == NULL)
        {
            cout << "The file can not be opened" << endl;
            exit(0);
        }
    else if...
}

operation result

Command line parameters input error

Modify the existing code
else branch changed

else if(strcmp(argv[1], "-c") == 0 || strcmp(argv[1], "-w") == 0 || strcmp(argv[1], "-l") == 0 \
        || strcmp(argv[1], "-a") == 0 || strcmp(argv[1], "-o") == 0)
else
    {
        cout << "input error!" << endl;
    }

Test Results

Describe the process of twinning

Job feelings

Pair programming can find other issues with each other, compared to a single person to complete tasks more efficiently in the future project work can be timely use of pair programming work, for completion of the project efficiency and quality have helped.

Guess you like

Origin www.cnblogs.com/xxxy7280/p/11660510.html