第四周WordCount小组作业

一、基础功能

小组github地址:https://github.com/kawoyi/Advanced-WordCounter

PSP表格:

接口的实现:

我实现的是单词的统计模块,由Counter类完成,其中最主要的功能是由analyse()函数完成功能是将分割出单词并且加入map中供输出结果

public void analyse()//主要功能实现
{
strToken = ""; // 置strToken为空串
while (i < buffer.length())
{
getChar();
getBc();
if (isLetter())
{ // 如果ch为字母
while (isLetter() ||isConnector())
{
concat();
getChar();
}
validLize();
retract(); // 回调
if(!map.containsKey(strToken))
{
map.put(strToken, 1) ;
}else{
int temp=map.get(strToken)+1;
map.put(strToken, temp);
}
System.out.println(strToken);
strToken = "";
}
}
}

主要思路是将文件字符读入缓存区buffer中然后利用charAt()函数和游标i进行读取的控制,并且加以单词的逻辑判断从而得到单词。

本次测试用例的设计采用了白盒测试和黑盒测试的思想。其实前三个测试就可以覆盖模块所有分支,因此前三个用例偏向白盒测试。后面的测试主要是黑盒测试,偏重于考虑各种输入所带来的结果,每个用例针对于某种可能的异常情况。

测试脚本实例:

@Test
public void testAnalyse() {
count.setFilepath("input.txt");

FileUnit.readFile(count.getFilepath(), count.getBuffer());
}

将输出结果result.txt文件与自己提前输入好的结果文件进行对比

单元测试运行和评价:

如图所示对模块各部分进行了测试并且包括了模块的每个语句和分支,考虑了各种边界条件和情况,单元测试效率较高

二、扩展功能

开发规范分析:

邹欣老师对代码规范和代码复审的讨论:http://www.cnblogs.com/xinz/archive/2011/11/20/2255971.html

下面选取其中两个规范进行分析

boolean isSeperator()
{
boolean flag=false;
for(int i=0;i<Define.seperator.length;i++)
{
if(ch==Define.seperator[i])
{
flag=true;
}
}
return flag;
}

1.命名规范:使用了驼峰命名法,参数名统一

2.缩进对齐,代码段层次分明

交叉代码评审:

评审对象 U201517107 赵国伟

public static void readFile(String filepath,StringBuffer buffer) //读取文件
{
try {
FileReader fis = new FileReader(filepath);
BufferedReader br = new BufferedReader(fis);
int temp=-1;
while ((temp = br.read()) != -1)
{
buffer.append((char)(temp));
}

} catch (FileNotFoundException e) {
System.out.println("源文件未找到!");
e.printStackTrace();
} catch (IOException e) {
System.out.println("读写文件出现异常!");
e.printStackTrace();
}

}

可以看到这份代码风格是比较不错的,符合邹欣老师提到的规范,例如命名ReadFile让人一下就知道是文件读取函数,同时对于异常的处理也是十分清晰。

组内代码评审:

小组成员的代码基本没有什么大问题,只要是在命名上个人的风格不好统一,同时的话代码的优化还有待提升,代码执行效率不是很高。

小组贡献分:

0.25

原文地址:https://www.cnblogs.com/Ussr/p/8747989.html

时间: 2024-08-01 00:26:51

第四周WordCount小组作业的相关文章

WordCount小组作业

一.github地址 https://github.com/Adogssky/WordCountGroupWork 二.psp表格 PSP2.1表格 PSP2.1 PSP阶段 预估耗时 (分钟) 实际耗时 (分钟) Planning 计划     · Estimate · 估计这个任务需要多少时间 425  400 Development 开发     · Analysis · 需求分析 (包括学习新技术)  30  30 · Design Spec · 生成设计文档  60 45  · Des

第四周小组作业:WordCount优化

Github地址: https://github.com/skz12345/wcPro PSP表格: PSP PSP阶段 预估耗时(分钟) 实际耗时(分钟) Planning 计划 10 5 Estimate 估计这个任务需要多少时间 10 5 Development 开发 60 50 Analysis 需求分析(包括学习新技术) 5 5 Design Spec 生成设计文档 5 5 Design Review 设计复审(和同事审核文档) 5 5 Coding Standard 代码规范(为目前

第4周小组作业:WordCount优化

第4周小组作业:WordCount优化 一.基本任务:代码编写+单元测试 小组github 地址 https://github.com/iwannastay/WcPro PSP表格 PSP2.1 PSP阶段 预估耗时(分钟) 实际耗时(分钟) Planning 计划 30 60 Estimate 估计任务需要多少时间 30 60 Development 开发 180 240 Analysis 需求分析 20 30 Design Spec 生成设计文档 20 30 Design Review 设计

软件质量与测试第4周小组作业:WordCount优化

软件质量与测试第4周小组作业:WordCount优化 一.GitHub地址 https://github.com/fusidic/WC 二.PSP表格 PSP2.1 PSP阶段 预估耗时(分钟) 实际耗时(分钟) Planning 计划 30 20 · Estimate · 估计这个任务需要多少时间 30 20 Development 开发 470 550 · Analysis · 需求分析 (包括学习新技术) 30 20 · Design Spec · 生成设计文档 20 20 · Desig

第四周小组作业wcPro

第四周小组作业wcPro 1  基本任务:代码编写+单元测试 1.1 小组github地址 github.com/Asfalas/wcPro 1.2 PSP表格 PSP2.1 PSP阶段 预估耗时(分钟) 实际耗时(分钟) Planning 计划 30 60 Estimate 估计任务需要多少时间 30 60 Development 开发 180 230 Analysis 需求分析 20 10 Design Spec 生成设计文档 20 20 Design Review 设计复审 20 20 C

软件测试第4周小组作业:WordCount优化

小组github地址 https://github.com/whoNamedCody/wcPro  基本任务 一.PSP表格 PSP2.1 PSP阶段 预估耗时 (分钟) 实际耗时 (分钟) Planning 计划  20  20 · Estimate · 估计这个任务需要多少时间  10  10 Development 开发  60  60 · Analysis · 需求分析 (包括学习新技术)  20  15 · Design Spec · 生成设计文档  50  60 · Design R

第4周小组作业 WordCount优化

github地址:https://github.com/husterC/WordCountGroupwork PSP表格 PSP2.1 PSP阶段 预估耗时 (分钟) 实际耗时 (分钟) Planning 计划  20  20 · Estimate · 估计这个任务需要多少时间  15  10 Development 开发  60  40 · Analysis · 需求分析 (包括学习新技术)  60  90 · Design Spec · 生成设计文档  -  - · Design Revie

第四周小组作业

基本任务 1.小组Github 我们小组成员:袁寅申(组长).胡聪.何啸轩.王思哲 github地址:https://github.com/YinshenYuan/wcPro 2.PSP表格 3.接口实现 在项目中我负责输入模块的实现,组长给到我函数原型是: public static String getContent(String inFilePath) { String content = null; // TODO read the file content from inFilePat

软件测试第四周作业 WordCount优化

Github地址 https://github.com/husterC/WordCountGroupwork PSP表格 PSP2.1 PSP阶段 预估耗时 (分钟) 实际耗时 (分钟) Planning 计划     · Estimate · 估计这个任务需要多少时间 540  780 Development 开发     · Analysis · 需求分析 (包括学习新技术)  60  120 · Design Spec · 生成设计文档  30  10 · Design Review ·