PSP2.1 | PSP 阶段 | 预估耗时 (分钟) | 实际耗时 (分钟) |
---|---|---|---|
Planning | 计划 | 25 | 30 |
· Estimate | · 估计这个任务须要多少时间 | 20 | 30 |
Development | 开发 | 130 | 270 |
· Analysis | · 需求分析 (包括学习新技术) | 15 | 20 |
· Design Spec | · 生成设计文档 | 0 | 0 |
· Design Review | · 设计复审 (和同事审核设计文档) | 0 | 0 |
· Coding Standard | · 代码规范 (为目前的开发制定合适的规范) | 2 | 2 |
· Design | · 具体设计 | 20 | 30 |
· Coding | · 具体编码 | 120 | 150 |
· Code Review | · 代码复审 | 20 | 10 |
· Test | · 测试(自我测试,修改代码,提交修改) | 10 | 60 |
Reporting | 报告 | 60 | 30 |
· Test Report | · 测试报告 | 10 | 5 |
· Size Measurement | · 计算工做量 | 10 | 5 |
· Postmortem & Process Improvement Plan | · 过后总结, 并提出过程改进计划 | 20 | 20 |
合计 | 462 | 642 |
https://github.com/dashmrl/WC.gitgit
将不一样的选项参数交由不一样的函数处理。github
空格、逗号和句号做为分隔符,连续空格视为一个空格。app
支持的参数使用枚举类来定义,过滤掉不支持的参数。函数
参数枚举类单元测试
enum class Options(val value: String) { C("-c"),// 字符数 W("-w"),// 单词数 L("-l"),// 行数 O("-o")// 输出文件 }
参数检查函数学习
fun checkArgs(pindex: Int, pc: Int, msg: String): Boolean { if (pindex <= -1) return false if (pindex + 1 == pc) { throw IllegalArgumentException(msg) } return true }
单词统计函数测试
fun calWordCount(ifile: File): Int { println("start calculating word count") return ifile.readLines().sumBy { it.split( ' ', ',', '.', ignoreCase = false, limit = 0).filter { it.isNotEmpty() }.size } }
输出结果函数ui
fun outputResult(input: String, cc: Int, wc: Int, lc: Int, of: File) { val sb = StringBuilder(input) if (cc != -1) { sb.append(",").append(Options.C.value).append(":").append(cc) } if (wc != -1) { sb.append(",").append(Options.W.value).append(":").append(wc) } if (lc != -1) { sb.append(",").append(Options.L.value).append(":").append(lc) } if (of.exists() && of.isFile) { of.delete() } println("write the result to ${of.absolutePath}") of.writeText(sb.toString()) }
WordCount.exe -c input.txt WordCount.exe -w input.txt WordCount.exe -l -o result.txt input.txt WordCount.exe -c -w -l -o result.txt input.txt
系统测试在测试中占比很是小的部分,收益远没有单元测试高。编码
jar 包打包成 exe 不论对于测试和做业,都显得很是多余,找打包软件花费至少半天时间。设计