zoukankan      html  css  js  c++  java
  • 第二次博客作业

    一、是否需要有代码规范

    1.“这些规范都是官僚制度下产生的浪费大家的编程时间、影响人们开发效率, 浪费时间的东西。

      其实好的代码风格自然而然就形成了,比如等号两边的空格和大括号的位置,形成习惯之后并不会浪费时间,反而是写的乱七八糟的话之后的复查会浪费时间。

    2.“我是个艺术家,手艺人,我有自己的规范和原则

      额...再艺术也是个程序员吧...如果说你写的代码只由你来维护的话就算写成梵高的画也没关系,但是代码是永存的,人是会被拍在沙滩上的,还是能让大家读懂的好。

    3.“规范不能强求一律,应该允许很多例外。

      一堆例外的话,还怎么规范啊...虽然没有什么“程序员法”来规定代码必须按怎么样的样式写,但一个大家都已经默认的规范打破他也没有什么好处。

    4.“我擅长制定编码规范,你们听我的就好了。

      如果真的是那样的话其实也不错啊...如果真的有比现在更好的代码规范那我愿意使用。

    二、代码复审

    1.Does the code work? Does it perform its intended function, the logic is correct etc.

      能够正常输出表达式到文件,也支持答案对比检测功能。

    2.Is all the code easily understood?

      如果从中国程序员的角度真的很好理解(因为用了拼音表示变量)...但是最好还是用英语来表示变量吧。截取代码片段如下:

     1 //除法
     2 Digital Digital::DivDigital(Digital anDigital)
     3 {
     4     long long miFenzi;
     5     long long miFenmu;
     6     long long anFenzi;
     7     long long anFenmu;
     8 
     9     if (fenzi == 0)
    10     {
    11         miFenzi = num;
    12         miFenmu = 1;
    13     }
    14     else
    15     {
    16         miFenzi = fenzi + num * fenmu;
    17         miFenmu = fenmu;
    18     }
    19 
    20     if (anDigital.fenzi == 0)
    21     {
    22         anFenzi = 1;
    23         anFenmu = anDigital.num;
    24     }
    25     else
    26     {
    27         anFenzi = anDigital.fenmu;
    28         anFenmu = anDigital.fenzi + anDigital.num * anDigital.fenmu;
    29     }
    30 
    31     long long sumFenzi = miFenzi * anFenzi;
    32     long long sumFenmu = miFenmu * anFenmu;
    33 
    34     if (sumFenzi == 0 || sumFenmu == 0)
    35     {
    36         num = 0;
    37         fenzi = 0;
    38         fenmu = 0;
    39     }
    40     else
    41     {
    42         num = sumFenzi / sumFenmu;
    43 
    44         fenzi = sumFenzi % sumFenmu;
    45 
    46         fenmu = sumFenmu;
    47         Simplify();
    48     }
    49     return *this;
    50 }

    3.Does it conform to your agreed coding conventions? These will usually cover location of braces, variable and function names, line length, indentations, formatting, and comments.

      额,代码的形式风格还是很相似的(也许是因为vs的强制规范风格),但是我的变量名用的是英文表示,较长的英文则取单词的前三至四个字母表示。他在每个函数/方法前简要的注释了一下,我也是如此。

    4.Is there any redundant or duplicate code?

      该代码冗余较低,计算方法和数的存储都比较简洁。

    5.Is the code as modular as possible?

      还不是十分的模块化。

    6.Can any global variables be replaced?

      并没有全局变量。

    7.Do loops have a set length and correct termination conditions?

      是的。截取以下代码为例:

     1 long long getLong(char * str)
     2 {
     3     long long l = 0;
     4     int i = 0;
     5     while (str[i] != '')
     6     {
     7         l = l * 10 + str[i] - '0';
     8         i++;
     9     }
    10     return l;
    11 }

    8.Are all data inputs checked (for the correct type, length, format, and range) and encoded?

      测试了一些边界数据均有相应的处理。

    9.Where third-party utilities are used, are returning errors being caught?

      并没有使用第三方程序

    总结

      第一次作业我使用的是c#语言编写的,而我的结对伙伴是使用的c++语言,我对c++语言了解较少,所以很多地方都是通过结对伙伴的讲解才了解到的,因此我从此次结对项目中获得了很多。

  • 相关阅读:
    Paxos算法简单陈述
    二段式提交和三段式提交
    Guava包学习--Hash
    JedisPool无法获得资源问题
    有料面试题之--Object里面的方法
    Spring常用jar包的功能
    线上日志分析与其他一些脚本
    Flutter-漸變色按鈕
    Flutter-自定義圖標或者選擇框
    Flutter-自定義圖片圖標
  • 原文地址:https://www.cnblogs.com/geminy/p/4850093.html
Copyright © 2011-2022 走看看