Soft-tasking - Pair Programming

First, at the beginning of the requirements

GitHub address
my partner's address

Two, PSP form

PSP2.1 Personal Software Process Stages Estimated time consuming (minutes) The actual time-consuming (minutes
Planning plan 120 180
· Estimate • Estimate how much time this task requires 1440 1500
Development Develop 720 600
· Analysis · Needs analysis (including learning new technologies) 300 240
· Design Spec Generate design documents 120 100
· Design Review · Design Review (and his colleagues reviewed the design documents)
· Design Review · Code specifications (development of appropriate norms for the current development) 60 30
· Design · Specific design 250 300
· Coding · Specific coding 740 600
· Code Review Code Review 180 120
Test · Test (self-test, modify the code, submit modifications) 300 360
Reporting report **** ****
· Test Report · testing report
· Size Measurement · Computing workload ****
· Postmortem & Process Improvement Plan · Hindsight, and propose process improvement plan
total

Third, to achieve the program's

1, problem-solving ideas

对这个问题的大致解题阶段:

拿到这个题目的时候,因为他要实现的功能相对较多。所以,我先对每一个要实现的功能设计了函数。

所以,我先对每一个要实现的功能设计了函数。下面是一些我认为相对来说比较麻烦的功能的实现:

(1): statistics on the specified file appear in the string

(2): Specifies the string of maximum assessment rate of 10 strings that appear in the statistics file.

2, the package of the class

一共两个类:
基类:
class word_count 
{
public:
    void f_open();/*打开文件函数*/
    void count_acill();/*统计文件中出现的acill 码*/
    void count_aphabet();/*统计文件中出现的字母*/
    void count_Enum();/*统计文件中出现的字母*/
    void count_seperetors();/*统计文件中出现的分割符号*/
    void count_line();/*存储文件中的每一行的字符串*/
    void display_1();
protected:
    ifstream f_in;
private:
    int acill;
    int aphabate;
    int Enum;
    int seperetors;
    string line_count[MAX];
    string line_count_all[MAX];
};

Inheritance categories:

class word_count2 :public word_count
{
public :
    void read_str();
    void store_str(string s);
    void display();
    void count_limit();
    void ruin_node();
private:
    count_str *first, *rear;
};

Fourth, code review

(1) Self-review

   写了一点代码,我发现对于像我现在这个阶段。完整的写一段代码花费时间更多的是在后面的修改代码上面。原因是:首先,自己写代码用的算法都是已经存在,没有说自己设计一个算法去写一段代码。其次,自己对很多语法不熟悉,每次编译的时候没有问题但是运行就会出错。最后,对整段代码的分析不到位,得不到自己想要的结果。
这次写代码,在写函数统计文件中出现的频数最大的10个字符串的时,就遇到了一个让我很恼火的问题。在这里我也花费了很多的时间去修改。但是最后我还是放弃了重写一段代码来代替他。    
   未修改前的思路:

修改后的思路:

(2) Peer review

经过了这次同伴复审后,我发觉有一个同伴来审查自己写的代码会提高自己写代码的效率。
###(1)提高自己代码的运行可信度。
这次写函数统计指定字符的时候,我忘记了"123file"这一类不是单词,不能被写入。
起始代码是这样的:
void word_count2::read_str()
{
    char ch;//收集每一个文件中字符
    string str_1;//记录每一个规定的字符
    long pos;//记录f_in的位置
    int fir = 0;//判断第一个字符是否为字母
    f_in.clear();
    f_in.seekg(0, ios::beg);

    while (!f_in.eof())
    {
                int read=0;
        f_in.get(ch);
        
                
    
                read++;
                int k;
                f_in.seekg(pos);
                //f_in.get(ch);
                
                for ( k = 1; k < 4; k++)
                    {
                        read++;
                        f_in.get(ch);
                        if ( ch<'A' || (ch > 'Z'&& ch < 'a') || ch>'z' ) break;
                    }
                if (k == 4)
                {
                    f_in.get(ch);
                    while (('a' <= ch && 'z' >= ch) || ('A' <= ch && 'Z' >= ch)|| ( '0' <= ch && ch <= '9'))
                    {
                        f_in.get(ch);
                        read++;
                    }
                    pos = f_in.tellg();
                    f_in.seekg(pos - read);
                    getline(f_in, str_1, ch);
                    store_str(str_1);
                    f_in.seekg(pos);

                }
        

            }
        
    }
}
   经过我的好伙伴的提醒我就有修改了代码,如下:
void word_count2::read_str()
{
    char ch;//收集每一个文件中字符
    string str_1;//记录每一个规定的字符
    long pos;//记录f_in的位置
    int fir = 0;//判断第一个字符是否为字母
    f_in.clear();
    f_in.seekg(0, ios::beg);

    while (!f_in.eof())
    {
        f_in.get(ch);
        fir++;
        if (('a' <= ch && 'z' >= ch) || ('A' <= ch && 'Z' >= ch))
        {
            
            int read=1;//记录规定字符创的长度。
                        //-------------------------------------------------->增加代码
            if (fir == 1)
            {
                pos = f_in.tellg();
                
            }
            else
            {

                pos = f_in.tellg();
                f_in.seekg(pos-1);//得到上一个字符
                f_in.get(ch);
            }
            
            if (('0' <= ch && ch <= '9') || ch== '" ')
            {
                f_in.seekg(pos);
                f_in.get(ch);
                while (('a' <= ch && 'z' >= ch) || ('A' <= ch && 'Z' >= ch) || ('0' <= ch && ch <= '9'))
                {
                    f_in.get(ch);
                }
            }//-------------------------------------------------------------------------------------------------------------------
            else
            {
                read++;
                int k;
                f_in.seekg(pos);
                //f_in.get(ch);
                
                for ( k = 1; k < 4; k++)
                    {
                        read++;
                        f_in.get(ch);
                        if ( ch<'A' || (ch > 'Z'&& ch < 'a') || ch>'z' ) break;
                    }
                if (k == 4)
                {
                    f_in.get(ch);
                    while (('a' <= ch && 'z' >= ch) || ('A' <= ch && 'Z' >= ch)|| ( '0' <= ch && ch <= '9'))
                    {
                        f_in.get(ch);
                        read++;
                    }
                    pos = f_in.tellg();
                    f_in.seekg(pos - read);
                    getline(f_in, str_1, ch);
                    store_str(str_1);
                    f_in.seekg(pos);

                }
        }

            }
        
    }
}
   这样的事情在这次的作业中还出现了很多次,这里就不在都说了。GitHub上的代码就是我和我的同伴经过相互修改后的最终结果。
   ##(2)同伴互审可以学到对方写代码很多好的方法和习惯。

Fifth, the display calculation module of the unit test.

1, part of the code improvement ideas:

2, FIG Performance Analysis:


消耗最大的函数:

Guess you like

Origin www.cnblogs.com/kadcyh/p/11631709.html