于鑫宇

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

结对作业

结对成员:唐杰2016012058  于鑫宇2016012029

一、代码仓库地址:https://git.coding.net/jyuegq/project2.git

2.PSP

PSP 任务内容 计划共完成需要的时间 实际完成需要的时间
Planning 计划  一周  *
Estimate 估计这个任务需要多少时间,并规划大致工作步骤  一周  *
Development 开发  4天 *
 Analysis  需求分析 (包括学习新技术)  3.5(h) *
Design Spec  生成设计文档  2(h)  *
Design Review 设计复审 (和同事审核设计文档)  1(h) *
Coding Standard 代码规范 (为目前的开发制定合适的规范)  1(h) *
Design 具体设计  1h *
 Coding 具体编码  2天 *
 Code Review 代码复审  1(h) *
Test 测试(自我测试,修改代码,提交修改)  2(h) *
Reporting 报告  2h  *
Test Report  测试报告  1.5h  *
Size Measurement  计算工作量  30min  *
 Postmortem & Process Improvement Plan 事后总结, 并提出过程改进计划 20min  

3.Information Hiding:将上限和下界私有化,仅提供对外的使用方法,从而提高了代码安全性,改变人机交互模式的时候就不会给系统带来全局性的影响

 Interface Design:在本项目设计接口过程中,使用有意义的命名方式使接口的功能一目了然,增强了可读性;类名和方法名也都使用了有意义的命名方式;在开发过程中加好了注释,方便自己和他人看懂代码

Loose Coupling:将不同功能的代码封装到不同的方法中,减小耦合度

4.计算模块共分为八个类。  如下图

 

五、计算模块接口部分的性能改进

用JProfiler做的效能分析 内存分析

 

 

六、计算模块部分单元测试展示

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import java.io.IOException;
import java.util.ArrayList;
 
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
 
import IO.anwser;
import Jisuan.creat;
import Jisuan.creat2;
import Jisuan.creat3;
import Jisuan.dangejisuan;
import Jisuan.jisuanshi;
import Jisuan.pinjie;
import entity.SuiJiShu;
import entity.YunSuanFu;
 
public class test {
    public static void main(String[] args) {
        creat c=new creat();
        String flag="yes";
        c.Create(7,4, 56, 5,flag);
         
        

 

  

 

 

七、计算模块部分异常处理说明

题目数目异常处理:

 

1
2
3
4
5
6
7
8
9
10
11
12
13
for (int i = 0; i < args.length; i++) {
        if (args[i].equals("-n")) {
            isN = 1;
            try {
                n = Integer.parseInt(args[i + 1]);
                if (n <= 0 || n > 10000) {
                    System.out.println("n的范围不在[1,10000]内,请重新输入");
                    return;
                }
            } catch (Exception e) {
                System.out.println("n的格式不合法,请重新输入!");
            }
        }

 

 界限的异常处理: 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
if (args[i].equals("-m")) {
                isM = 1;
                try {
                    m1 = Integer.parseInt(args[i + 1]);
                    m2 = Integer.parseInt(args[i + 2]);
                    if (m1 <= 0 || m1 > 100) {
                        System.out.println("m1的范围不在[1,100]内,请重新输入");
                        return;
                    }
                    if (m2 < 50 || m2 > 1000) {
                        System.out.println("m1的范围不在[50,1000]内,请重新输入");
                        return;
                    }
                } catch (Exception e) {
                    System.out.println("m的格式不合法,请重新输入!");
                }
            }

  括号与符号的异常处理:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
if (args[i].equals("-o")) {
                try {
                    o = Integer.parseInt(args[i + 1]);
                    if (o <= 0 || o > 10) {
                        System.out.println("o的范围不在[1,10]内,请重新输入");
                        return;
                    }
                } catch (Exception e) {
                    System.out.println("o的格式不合法,请重新输入!");
                }
            }
            if (args[i].equals("-b")) {
                b = 1;// 括号
            }
            if (args[i].equals("-c")) {
                c = 1;// 乘除
            }

8.由于时间紧张,加上对于GUI没有接触,故选用JSP页面作为界面。参照HTML格式以分区,利用输入框来键入要求

<div class="input-group w3_w3layouts">出题数目
			<input type="text" class="form-control" name="problem-number"placeholder="请输入数值" aria-describedby="basic-addon1">
</div>

  单选框来决定其余两个约定数

<div class="input-group w3_w3layouts">是否含有乘除
<input type="checkbox" name="select-chengchu" aria-label="...">
</div>

  整个页面只是粗略制作,并未加入美化。

9.界面为jsp文件,为了向后台传参的方便性,在界面输入时就引入form表单,在chaundi.java中使用request语句来获得参数

	public String getOperator() {
		return operator;
	}
	public void setOperator(String operator) {
		this.operator = operator;
	}
	public String getChengchu() {
		return chengchu;
	}
	public void setChengchu(String chengchu) {
		this.chengchu = chengchu;
	}

   然后在chuanservlet.java中转化为计算用的参数

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		System.out.println("content");
		request.setCharacterEncoding("utf-8");
		String problem = null,up= null,down = null,operator=null,chengchu=null;
	
	try {
			problem=request.getParameter("problem-number");
			System.out.println(problem);
			up=request.getParameter("up-number");
			System.out.println(up);
			down=request.getParameter("down-number");
			System.out.println(down);
			operator=request.getParameter("operator-number");
			System.out.println(operator);
			chengchu=request.getParameter("select-chengchu");
			System.out.println(chengchu);
			int n;
			int o;
			int m1;
			int m2;
			n=Integer.parseInt(problem);
			o=Integer.parseInt(operator);
			m1=Integer.parseInt(down);
			m2=Integer.parseInt(up);
			if(chengchu=="yes")
			{
				
			creat c=new creat();
			c.Create(n,m1, m2,o);
			}else {
				
				creat2 c=new creat2();
				c.Create(n,m1, m2,o);	
			}

  10.

 

  11.优点:(1)1+1>2

       (2)如果分工明确可以事半功倍

       (3)将减少枯燥感

    缺点:如果有卡壳的地方将会是两个人一起受苦.

13.

PSP 任务内容 计划共完成需要的时间 实际完成需要的时间
Planning 计划  一周  两周
Estimate 估计这个任务需要多少时间,并规划大致工作步骤  一周  一周
Development 开发  4天  4天
 Analysis  需求分析 (包括学习新技术)  3.5(h)  3(h)
Design Spec  生成设计文档  2(h)  2(h)
Design Review 设计复审 (和同事审核设计文档)  1(h)  1(h)
Coding Standard 代码规范 (为目前的开发制定合适的规范)  1(h)  40min
Design 具体设计  1h  35min
 Coding 具体编码  2天  6天
 Code Review 代码复审  1(h)  1(h)
Test 测试(自我测试,修改代码,提交修改)  2(h)  2(h)
Reporting 报告  2h  1.5h
Test Report  测试报告  1.5h  1h
Size Measurement  计算工作量  30min  30min
 Postmortem & Process Improvement Plan 事后总结, 并提出过程改进计划  30min  20min
posted on 2018-04-10 08:02  于鑫宇  阅读(203)  评论(0)    收藏  举报