首页 > 代码库 > 个人作业-Week3:代码复审

个人作业-Week3:代码复审

1.成长之路

14年夏,高考结束,我报了北航的计算机专业,由此踏上了成为程序员的道路。相比众多大神从中学甚至小学就开始的编程人生,我接触编程的日子还很短暂。两年的时间,也许还不足以让自己变得多么厉害,但比起当初那个什么都不懂的自己如今已经有不小的进步了,更重要的是,两年的时间让我确定了自己对编程的热爱,让我确定了当初的选择没有错,也确定了自己将会一直在这条路上走下去。

由于经历有限我也没太多可说的话。两年间,除了正常的课业外花费最多精力的就是ACM竞赛,也从这个竞赛中收获了无数痛苦和快乐,不过肯定还是快乐占了大多数,有时候甚至在想如果中学的时候就能为了信息学竞赛而奋斗该有多么幸福。

以后的路上,当然也不可能放弃ACM,不过也想接触一下更广阔的世界,体会一下做工程和做研究是什么样的感受。也没太多可说的话,姑且就这样吧。

2.代码复审

复审对象:冯炜韬

Code Review Checklist

General

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

    I tested the cases below, the function of -a and -b are correct in all cases. However, there‘s bug in the function of -c.

    起点终点最少站数最少换乘数

    最少换乘下的

    最少站数

    霍营马泉营717
    阜通天通苑南528
    T2航站楼南锣鼓巷626
    灵境胡同七里庄9113
    阜成门马泉营15215
    园博园石榴庄14114
    奥体中心天安门西11211
    望京西南邵11112
    西二旗青年路16216
    四惠东天通苑南15120
    四惠东沙河高教园22323
    郭庄子巩华城19322
    三元桥土桥20220
    荣京东街南礼士路18219
    南礼士路来广营16321
    奥林匹克公园T2航站楼929
    篱笆房和平门18319
    沙河沙河高教园101
    平西府西单13215
    关庄军事博物馆15219
    梨园回龙观25325
    天宫院枣营28230
    良乡南关管庄36336
    石榴庄大井11111
    安华桥后沙峪13115
    立水桥菜市口15116
    磁器口 良乡南关26226

    In the last case, the program give a wrong route in mode -c. The result is shown below:

    技术分享

    • The upper is right and lower is wrong.
  • Is all the code easily understood?    --Yes.
  • 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.    --Yes.
  • Is there any redundant or duplicate code?    --No.
  • Is the code as modular as possible?    --Almost.
  • Can any global variables be replaced?    --Maybe only one variable: subway_machine sm.
  • Is there any commented out code?    --Yes, but not much.
  • Do loops have a set length and correct termination conditions?    --Yes.
  • Can any of the code be replaced with library functions?    --I don‘t think there‘s any.
  • Can any logging or debugging code be removed?    --Yes.

Security

  • Are all data inputs checked (for the correct type, length, format, and range) and encoded?    --No.
  • Where third-party utilities are used, are returning errors being caught?    --Yes.
  • Are output values checked and encoded?    --Yes.
  • Are invalid parameter values handled?    --Yes.

Documentation

  • Do comments exist and describe the intent of the code?   --No.
  • Are all functions commented?    --No.
  • Is any unusual behavior or edge-case handling described?   --No.
  • Is the use and function of third-party libraries documented?   --No.
  • Are data structures and units of measurement explained?   --No.
  • Is there any incomplete code? If so, should it be removed or flagged with a suitable marker like ‘TODO’?   --No.

Testing

  • Is the code testable? i.e. don’t add too many or hide dependencies, unable to initialize objects, test frameworks can use methods etc.   --Yes.
  • Do tests exist and are they comprehensive? i.e. has at least your agreed on code coverage.   --No.
  • Do unit tests actually test that the code is performing the intended functionality?    --Yes.
  • Are arrays checked for ‘out-of-bound’ errors?   --Most but not all.
  • Could any test code be replaced with the use of an existing API?   --No.

个人作业-Week3:代码复审