Computing and software engineering work 4

Computing and software engineering work 4

Work requirements https://edu.cnblogs.com/campus/jssf/infor_computation17-31/homework/10534
Course objectives Complete the development of simple software features, simple code will be reviewed, learn pair programming, partner and teammates together to develop new features, will be the code unit testing, code analysis utilization
To achieve self-goal The main partner and teammate complete program development, code review, code is simple to modify the code pricey utilization
references https://blog.csdn.net/weixin_44396540/article/details/88085543 https://blog.csdn.net/lbj1260200629/article/details/89600055https://jingyan.baidu.com/article/4f34706e11e052e387b56dd2.html https://jingyan.baidu.com/album/f96699bbeeda8d894e3c1b8d.html?picindex=4 https://www.cnblogs.com/lsdb/p/9201029.html https://www.cnblogs.com/xinz/archive/2011/11/20/2255971.html https://www.cnblogs.com/xinz/archive/2011/08/07/2130332.html
Text of the job https://www.cnblogs.com/yangqiuyan/

Pre-class reading stage:

Lecture 3 pair programming (Pair Programming) and two co-
https://www.cnblogs.com/xinz/archive/2011/08/07/2130332.html
pair programming form:
In pair programming mode, a pair of programmers shoulder side by side, equally, complementary to development work. Two programmers sat side by side in front of a computer, with a display face, use the same keyboard with a mouse to work together. Together they analyze, design together with the write test cases, coding together, with unit testing, integration testing together, to write documents.
Pair programming advantages :( pair programming to get a higher input-output ratio)
(1) in 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, you embarrassed deserted, too embarrassed to 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.
Review stage:
the development of the review include: design review, code review, test plan review, document review.

review problem
Review emerging issues . A lack of deep understanding of human review procedures, reducing the review results;. B can not be sustained, regularly reviewed;. C do not understand the requirements and design of lead can not achieve comprehensive and effective review.
Team review of the shortcomings a. What to do when meeting a review? A team can not meet every day. To find a time everyone can attend, it is not easy; b many people involved, with varying degrees of understanding, review the speed and effectiveness can not be effectively balance - it was too soon do not understand, is too slow to waste. many people's time; c is precisely because of the cost, not in-depth review of all design and code;. d due to the large number of personnel, have face problem.

The two have worked together at different stages:
1. Bud (Forming)
2. Run-in phase (Storming)
3. Specification phase (Norming)
. 4. The creation stage (Performing)
5. Disintegration phase (Deforming)

Homework stages:

A job job :( peer review)

1. https://www.cnblogs.com/lazycat777/p/12483269.html
style code: code does not follow a fixed format retracted, position in parentheses are not added to the same, in line with the code name of the style and function specifications, there capitalization resolution. But not well add comments, can not be very good for code reuse.
Code design: function expression clear, fully defined. The header file is not complete and test the function of every array input needs to be redefined in the main function, low utilization rate. The maximum output of the array of sub-arrays, and the starting and ending position with the usual habits are not the same. Mainly counted from 0, 1 instead.

2. https://www.cnblogs.com/parida/p/12469460.html
coding style: Code written in strict accordance with the design code design format, indented, there are strict parentheses writing. For a named class and functions may also be given in accordance with the reasonable requirements of the case will be reasonable. Annotation well but gives no suggestive reference, is not conducive to reading and code reuse.
Code design: function code loops can be given explicitly, clear thinking, but did not achieve the maximum display the start and end of the sub-arrays and location. And not on the unit test code, do not know the code utilization.

3. https://www.cnblogs.com/hxf98/p/12483784.html
style code: code does not follow a fixed format retracted, position in parentheses are not added to the same, in line with the code name of the style and function specifications, there capitalization resolution. Can better add comments, program easier to read.
Code design: function expression clear, fully defined. However, to test the function of each input array needs to redefine the main function, low utilization rate. An array of sub-array output is the largest sub-arrays but not required in the start and end positions.

4. https://www.cnblogs.com/zxy123456/p/12449427.html
coding style: Code written in strict accordance with the design code design format, indented, there are strict parentheses writing. For a named class and functions may also be given in accordance with the reasonable requirements of the case will be reasonable. Human-computer interaction is also very friendly, but there was no good comments given in each category at a function or suggestive reference, is not conducive to code reuse and reading.
Code Design: function expression clear, fully defined, clear block, each can exhibit good properties and performance of the array, high integrity and completeness of the code. Test code is also very complete, you can clearly see the code run rate.

5. https://www.cnblogs.com/yuhanzhou/p/12361161.html
coding style: Code written in strict accordance with the design code design format, indented, there are strict parentheses writing. For a named class and functions may also be given in accordance with the reasonable requirements of the case will be reasonable. Human-computer interaction is also very friendly and very complex functions can be achieved. Although there is not much comment, but due to more output Chinese characters, it is well understood in terms of function codes to give prompt information, more conducive to the code read.
Code design: very comprehensive, but were unable to achieve a generation multi-channel topics, and the overall mark, given the statistical accuracy. Also easy to understand in terms of coding, but a lot of code repetition rate is high, a lot of things in a single cycle if repeated, may consider rewrite branch statement, improve the code efficiency of each sentence.

6. https://www.cnblogs.com/hyjlove/p/12367291.html
coding style: Code section shot in each well to follow the requirements of the code programming, but do not freeze in the code enclosed in the back specifications, read the code to cause a minor inconvenience. Code comments, while small, but there are many precautionary statements, with little effect on code reuse.
Code design: The program features a very complete and meet the selection varying degrees of difficulty (to how many decided to join the operator), but can not give a one-time multi-channel title and unify give the correct rate. And doing well in terms of human-computer interaction, precautionary statements in place, can give multiple selections.

7. https://www.cnblogs.com/wanghuiru/p/12460279.html
coding style: Code written in strict accordance with the design code design format, indented, there are strict parentheses writing. For a named class and functions may also be given in accordance with the reasonable requirements of the case will be reasonable. Human-computer interaction is also very friendly and very complex functions can be achieved. Although there is not much comment, but due to more output Chinese characters, it is well understood in terms of function codes to give prompt information, more conducive to the code read.
Code design: the overall integrity code is high, you can basically meet the requirements of pupils learning. However, many repeated passages in the code, the code is repeated many can be considered appropriately simplified. Separate part of the implementation of the test code, also see the utilization code. Under normal circumstances the code efficiency of 70 to 90 percent, can be well executed original function, it is not too low, it is possible to further modify the code.

8. https://www.cnblogs.com/shixiaomao12138/p/12404101.html
coding style: Code written in strict accordance with the design code design format, indented, there are strict parentheses writing. For a named class and functions may also be given in accordance with the reasonable requirements of the case will be reasonable. But not too many notes, but more because the output of Chinese characters, so in terms of understanding the code function well give prompt information, more conducive to the code read.
Code design: the code is relatively simple, although not achieve grades selection, but four rules of arithmetic and judgment of right and wrong aspects of the subject are full of it. But we can not do a one-time 100 questions and determine the overall accuracy. Out of the question due to the selection line of output is displayed so the layout is not perfect.

Overall summary:
1. The code style: in this regard in fact, most people will have programming experience good programming skills to follow strict parentheses wrap or other operations, but in annotation majority still can not very well give. In fact, the comments should be clear introduction, adding comments after the necessary functions and classes, they can easily future code reuse, easy to learn from other programmers to read and write, but also facilitate their examination. Preferably the entire front of the nature of the code written in the code for the entire function.

2. code design: code design basic can perform basic functions, in many cases it can also take into account the reasonable man-machine interactive interface. But in many cases they are not too concerned about duplicate code, may each write code to implement a function in the back and also the need to design a previously could not make good use of the previous code when a similar function. Code design is actually more of a way we did well to improve the utilization code. Although there is no beginning to end I have written, but can also be carried out in accordance with the requirements simply rewrite the code and reuse.

Two operations: pair programming

Specific requirements
1. achieve a simple and complete software tool (Chinese character text file statistics program): for the novel "Dream of Red Mansions" requirement can analyze the various characters come to the number of times each chapter gyrus respective arise, these statistics can write into a csv file format.
2. The unit test, regression test, performance test, the use of associated tools in the course of achieving the above program.
To practice Personal Software Process (PSP), and gradually record their own time spent in each part of software engineering.
The use of source code management system (GitHub, Gitee, Coding.net, etc.);
3. For the formation of the above-mentioned software programs, new text for the novel "Water Margin" analysis of the various chapters figures occurrences, to examine the code.
4. The above-described application development pair programming to record the new blog, especially needs to show pair that is programmed by a variety of forms, and the procedure for obtaining the "Dream of the Red" and "Water Margin" character appears various chapters and total number of characters present The total number of occurrences show by bar graphs, pie charts, tables and other forms.
Experimental results

Dream of Red Mansions

Chart intuitive:


CSV Output:


Test:

Outlaws

csv output:

Test:

PSP table:

PSP Personal Software Process Stages Estimated time consuming The actual time-consuming
Planning plan one day one day
Estimate Estimate how much time this task requires one week Two weeks
Development Develop one week More than a week
Analysis Needs analysis (including learning new technologies) Two days 3 days
Coding Standard Code Specification 1 hour 1 hour
Design Specific design 2 days 2 days
Coding Specific coding 3 days 5 days
Code Review Code Review 2 hours 3 hours
Test test 1 hour 2 hours
Reporting report 1 hour 2 hours
Size Measurement Computing workload 1 hour 1 hour
Postmortem&Process Improvement Plan Later summarized, and process improvement plan 1 hour 1 hour
total --- Two weeks Two weeks

Experimental Summary:

The job was first adopted pair programming code design methods, even by the two wheat communicate together to complete the job. Since the first use of the way, more innovative but also more challenging. In addition the job and not been prepared in accordance with our previous learning language. Although the beginning tried several learned the language, but the results did not achieve the expected results. Finally decided to refer to an online new language to write code in Python. During installation, in fact, we have encountered more problems. Taking into account the various versions of the problem, in the end we chose version 3.8, but in fact light download the software can not be achieved the subject requirements, must also find new library and drawing code is written, we can achieve the purpose of drawing. Writing rules Python language is also quite different and usually we learned the language, so this means a lot of work or network information.

When this job is mainly to learn Python and application software twinning program under the conditions of the code development, a combination of two people thought to understand a great extent, higher efficiency rate in problem solving, but realized early learning uneven distribution of work, not easy to improve efficiency.
The test frequency of occurrence tested two classic text characters perform character analysis and other operations, at the outset would like to develop in C ++ or Java language, but with further discovery, C ++ is only suitable text in English input analysis, Chinese less efficient, easily expressed. Reference network code, in fact, may soon find Python language more suited to the requirements of this experiment, so we chose to complete this experiment with Python language. More clearly you can count the number of character appearances, while tests by testing the code rate can also be analyzed.

Difficulties: install python and before software installation is not the same, mainly to control the background, along with the experimental needs in fact need to be further realized the need to install additional libraries. In the preparation of the test file, because the tasks in order of appearance reading order problems, there have been many times does not match the situation, and ultimately the Internet to find a similar wrong solution.

The need to solve the problem: this time we did not come up sub-chapter discussion and analysis tasks appearance frequency, if you want to break, in fact, to manual operation, and did not think a good solution. The final test is relatively simple, no way to analyze aspects of the code.

代码托管


此次托管只需将新文件直接提交到个人仓库中。
码云链接:https://gitee.com/yang_qiu_yan/ruangong

附录代码

红楼梦图标分析:

import jieba
from collections import Counter
import matplotlib.pyplot as plt
import numpy as np
class HlmNameCount():
    # 此函数用于绘制条形图
    def showNameBar(self,name_list_sort,name_list_count):
        # x代表条形数量
        x = np.arange(len(name_list_sort))
        # 处理中文乱码
        plt.rcParams['font.sans-serif'] = ['SimHei']
        # 绘制条形图,bars相当于句柄
        bars = plt.bar(x,name_list_count)
        # 给各条形打上标签
        plt.xticks(x,name_list_sort)
        # 显示各条形具体数量
        i = 0
        for bar in bars:
            plt.text((bar.get_x() + bar.get_width() / 2), bar.get_height(), '%d' % name_list_count[i], ha='center', va='bottom')
            i += 1
        # 显示图形
        plt.show()

    # 此函数用于绘制饼状图
    def showNamePie(self, name_list_sort, name_list_fracs):
        # 处理中文乱码
        plt.rcParams['font.sans-serif'] = ['SimHei']
        # 绘制饼状图
        plt.pie(name_list_fracs, labels=name_list_sort, autopct='%1.2f%%', shadow=True)
        # 显示图形
        plt.show()

    def getNameTimesSort(self,name_list,txt_path):
        # 将所有人名临时添加到jieba所用字典,以使jieba能识别所有人名
        for k in name_list:
            jieba.add_word(k)
        # 打开并读取txt文件
        file_obj = open(txt_path, 'rb').read()
        # jieba分词
        jieba_cut = jieba.cut(file_obj)
        # Counter重新组装以方便读取
        book_counter = Counter(jieba_cut)
        # 人名列表,因为要处理凤姐所以不直接用name_list
        name_dict ={}
        # 人名出现的总次数,用于后边计算百分比
        name_total_count = 0
        for k in name_list:
            if k == '熙凤':
                # 将熙凤出现的次数合并到凤姐
                name_dict['凤姐'] += book_counter[k]
            else:
                name_dict[k] = book_counter[k]
            name_total_count += book_counter[k]
        # Counter重新组装以使用most_common排序
        name_counter = Counter(name_dict)
        # 按出现次数排序后的人名列表
        name_list_sort = []
        # 按出现次数排序后的人名百分比列表
        name_list_fracs = []
        # 按出现次数排序后的人名次数列表
        name_list_count = []
        for k,v in name_counter.most_common():
            name_list_sort.append(k)
            name_list_fracs.append(round(v/name_total_count,2)*100)
            name_list_count.append(v)
            print(k+':'+str(v))
        # 绘制条形图
        self.showNameBar(name_list_sort, name_list_count)
        # 绘制饼状图
        self.showNamePie(name_list_sort,name_list_fracs)


if __name__ == '__main__':
    # 参与统计的人名列表,可修改成自己想要的列表
    name_list = ['宝玉', '黛玉', '宝钗', '元春', '探春', '湘云', '妙玉', '迎春', '惜春', '凤姐', '熙凤', '巧姐', '李纨', '可卿', '贾母', '贾珍', '贾蓉', '贾赦', '贾政', '王夫人', '贾琏', '薛蟠', '香菱', '宝琴', '袭人', '晴雯', '平儿', '紫鹃', '莺儿']
    # 红楼梦txt文件所在路径,修改成自己文件所在路径
    txt_path = 'D:\hlm.txt'
    hnc = HlmNameCount()
    hnc.getNameTimesSort(name_list,txt_path)

红楼梦效率分析及csv文件输出:

# 红楼梦
import jieba
import csv
class NameCount():
     def getNameTimesSort(self, name_list, txt_path):
         # 添加jieba分词
        mydict = ['琏二奶奶', '凤哥儿', '凤丫头', '宝姑娘', '颦儿', '二姑娘', '三姑娘', '四姑娘', '云妹妹', '蓉大奶奶']
        for item in mydict:
            jieba.add_word(item)
        #打开并读取txt文件
        txt = open(txt_path, "r", encoding='utf-8').read()
         # 定义别名列表
        bieming = [["王熙凤", "凤丫头", '琏二奶奶', '凤姐', '凤哥儿', '凤辣子','熙凤'],["林妹妹", "黛玉", '林姑娘', '林黛玉'], ["宝钗", '宝姑娘', '宝丫头', '宝姐姐', '薛宝钗'],
                   ['探春', '三姑娘', '贾探春'], ['湘云', '云妹妹', '史湘云'],['迎春', '二姑娘', '贾迎春'],['元春', '大姑娘', '娘娘', '贵妃', '元妃', '贾元春'],
                   ['惜春', '四姑娘', '贾惜春'], ['妙玉'],['巧姐'], ['李纨', '大嫂子'], ['秦可卿', '可卿', '蓉大奶奶']]
        words = jieba.lcut(txt)
        counts = {}
        for word in words:
            if len(word) == 1:
                continue
            else:
                counts[word] = counts.get(word, 0) + 1
        # 计算出场次数(各个别名的合计次数)
        lst = list()
        for i in range(12):
            lt = 0
            for item in bieming[i]:
                lt += counts.get(item, 0)
            lst.append(lt)
        items = list()
        for i in range(12):
            items.append([name_list[i], lst[i]])
        items.sort(key=lambda x: x[1], reverse=True)
        f = open('红楼梦人物统计.csv', 'w', newline='', encoding='utf-8')
        csv_writer = csv.writer(f)
        csv_writer.writerow(['红楼梦人物统计'])
        csv_writer.writerow(["姓名", "出现次数"])
        for i in range(12):
            word, count = items[i]
            csv_writer.writerow([word, count])
            print("{0:<10}{1:>5}".format(word, count))
        f.close()
        return items
if __name__ == '__main__':
    # 参与统计的人名列表,可修改成自己想要的列表
    name_list = ['熙凤', '黛玉', '宝钗', '探春', '湘云', '迎春', '元春', '惜春', '妙玉', '巧姐', '李纨', '可卿']
    # txt文件所在路径
    txt_path = 'D:\hlm.txt'
    NameCount().getNameTimesSort(name_list,txt_path)
    import pstats
import profile
if __name__ == '__main__':
    profile.run('NameCount()', 'result')
    # 直接把分析结果打印到控制台
    p = pstats.Stats('result')  # 创建Stats对象
    p.strip_dirs().sort_stats("call").print_stats()  # 按照调用的次数排序
    p.strip_dirs().sort_stats("cumulative").print_stats()  # 按执行时间次数排序

红楼梦各类测试

import unittest
from hlmcsv import*
class MyTestCase(unittest.TestCase):
    def setUp(self):
        pass
    def test_something(self):
        name_list = ['熙凤', '黛玉', '宝钗', '探春', '湘云', '迎春', '元春', '惜春', '妙玉', '巧姐', '李纨', '可卿']
        txt_path = 'D:\hlm.txt'
        name_list_count = [1149, 953, 696, 448, 393, 146, 126, 105, 81, 40, 36, 14]
        items = list()
        for i in range(12):
            items.append([name_list[i], name_list_count[i]])
        self.assertEqual(items, NameCount().getNameTimesSort(name_list,txt_path))
    def tearDown(self):
        pass
if __name__ == '__main__':
    unittest.main()

水浒传csv文件输出及效能测试

#水浒传
import jieba
import csv
import pstats
import profile
class NameCount():
    def getNameTimesSort(self, name_list, txt_path):
        mydict = ['及时雨','黑旋风', '行者','豹子头','花和尚', '智多星',  '玉麒麟', '神行太保', '小李广','九纹龙','青面兽', '高太尉','鼓上蚤']
        for item in mydict:
            jieba.add_word(item)
        txt = open(txt_path, "r", encoding='utf-8').read()
        bieming = [['及时雨', '宋江', '呼保义', '孝义黑三郎', '宋公明', '宋押司'],['黑旋风', '李逵', '铁牛'],['武松', '武二郎', '行者', '武行者', '武都头'],['豹子头', '林冲', '林教头'],
                   ['鲁提辖', '鲁达', '智深', '花和尚', '鲁智深'],['智多星', '吴用', '吴学究', '吴加亮', '赛诸葛', '加亮先生'],['卢俊义', '玉麒麟', '卢员外'], ['戴宗','戴院长','神行太保'],['花荣', '花知寨', '小李广'],
                   ['九纹龙', '史进'], ['杨志', '杨制使', '杨提辖', '青面兽'], ['高俅,‘高二','高太尉'],['时迁','鼓上蚤'] ]
        words = jieba.lcut(txt)
        counts = {}
        for word in words:
            if len(word) == 1:
                continue
            else:
                counts[word] = counts.get(word, 0) + 1
        # 计算出场次数(各个别名的合计次数)
        lst = list()
        for i in range(13):
            lt = 0
            for item in bieming[i]:
                lt += counts.get(item, 0)
            lst.append(lt)
        items = list()
        for i in range(13):
            items.append([name_list[i], lst[i]])
        items.sort(key=lambda x: x[1], reverse=True)
        f = open('水浒传人物统计.csv', 'w', newline='', encoding='utf-8')
        csv_writer = csv.writer(f)
        csv_writer.writerow(['水浒传人物统计'])
        csv_writer.writerow(["姓名", "出现次数"])
        for i in range(13):
            word, count = items[i]
            print("{0:<10}{1:>5}".format(word, count))
            csv_writer.writerow([word, count])
        f.close()
        return items
if __name__ == '__main__':

    # 参与统计的人名列表,可修改成自己想要的列表
    name_list = ['宋江', '鲁智深', '花荣', '武松', '吴用', '高俅', '史进', '卢俊义', '李逵', '林冲',  '杨志','戴宗','时迁']
    # 水浒传txt文件所在路径
    txt_path = 'D:\shz.txt'
    NameCount().getNameTimesSort(name_list, txt_path)
    print("效能测试:")
    profile.run('NameCount()', "result")
    # 直接把分析结果打印到控制台
    p = pstats.Stats('result')  # 创建Stats对象
    p.strip_dirs().sort_stats("call").print_stats()  # 按照调用的次数排序
    p.strip_dirs().sort_stats("cumulative").print_stats()  # 按执行时间次数排序

水浒传测试文件

import unittest
from shzcsv import*

class MyTestCase(unittest.TestCase):
    def test_something(self):
        name_list = ['宋江','鲁智深 ', '花荣', '武松',  '吴用','高俅','史进 ', '卢俊义','李逵', '林冲', '杨志', '戴宗','时迁']
        txt_path = 'D:\shz.txt'
        name_list_count = [2765, 1247, 1151, 759, 647, 639, 632, 343, 282, 242, 239, 216,183]
        items = list()
        for i in range(13):
            items.append([name_list[i], name_list_count[i]])
        self.assertEqual(items, NameCount().getNameTimesSort(name_list, txt_path))


if __name__ == '__main__':
    unittest.main()

Guess you like

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