OO第十二次作业

  任务一:调研,总结介绍规格化设计的大致发展历史和为什么得到了人们的重视

    随着计算机行业的不断发展,工程变得越来越庞大和复杂,不同人在阅读代码时总需要花费很长时间,甚至代码原作者都可能在一段时间后完全忘记代码的意义。这时工程化规格化也慢慢的受到了重视。标准化工作的最终目的就是使企业代码的作用和具体使用方法能一目了然。标准化规格化的推进对这一点发挥了举足轻重的作用。

  任务二:作业报告

  bug报告:

  bug数量  bug类型具体描述
第九次作业 0  无,测试者未测试
第十次作业 2

 gui:在复制新gui时忘记将时间改为500ms

关闭道路:临时关闭道路时车不能绕路选择新的最短路径行驶

第十一次作业 0  无

  被报告的规格相关bug:无,感觉大家对规格设计相关bug都没有很强的确定性,不敢乱报

  前置条件的不好写法:

  原写法  改进写法
第九次作业City.java构造器 a.length == 6400 &&a[i].length == 4&&Gui!=null; a.length == 6400 &&\all i 0<=i<6400 a[i].length == 4&&Gui!=null;
第九次作业:获取周围的点 None 0<= this.src <6400;
第九次作业:RequestQueue.offer(CR a) None a != null;
第九次作业&第十次作业:Scheduler构造器 None  Que!=null&&city!=null&&taxis!=null;
第九次作业&第十次作业:CustomerRequest构造器 None 0<=src1<80&&0<=src2<80&&0<=dst1<80&&0<=dst2<80;

 

  后置条件的不好写法:

 

  原写法  改进写法
第九次作业:开关道路的函数

@EFFECTS:\this.CityMap[a1][i]===>
* \this.CityMap[a1][i] == false;
* \this.isChanged[a1][i] == true;
* \result == 0;
*
* !\this.CityMap[a1][i]&&this.isChanged[a1][i] ===>
* \this.CityMap[a1][i] == true;
* \this.isChanged[a1][i] == false;
* \result == 1;
* else System.out.printLn("Wrong Roads.");

@EFFECTS:\this.CityMap[a1][i]===>
* \this.CityMap[a1][i] == false;
* \this.isChanged[a1][i] == true;
* \result == 0;
*
* !\this.CityMap[a1][i]&&this.isChanged[a1][i] ===>
* \this.CityMap[a1][i] == true;
* \this.isChanged[a1][i] == false;
* \result == 1;
* else System.out.printLn("Wrong Roads.");

* \result == -1;

第十次作业:设置TrafficLight

\TrafficLight.txt renewed;
* \result === fw;

\result === fw;
第十次作业:CustomerRequest repOk \result = (this.src >=0 &&this.src <6400&&this.dst >=0 &&this.dst <6400&&taxis!=null);

 (this.src >=0 &&this.src <6400&&this.dst >=0 &&this.dst <6400&&taxis!=null) ===> \result == true;

\result == false;

第九次,第十次,第十一次作业:出租车状态函数

this.situation == 2 ===>\result == "Wait For Service";
* this.situation == 1 ===>\result == "In Service";
* this.situation == 3 ===>\result == "Go to Service";
* this.situation == 0 ===>\result == "Stop";

this.situation == 2 ===>\result == "Wait For Service";
* this.situation == 1 ===>\result == "In Service";
* this.situation == 3 ===>\result == "Go to Service";
* \result == "Stop";
第十一次作业:VIPtaxis构造器

\this.situation == situ;
* \this.locations == loc;
* \this.credits == credits;
* \this.cityMap == map;
* \this.startTime == starttime;
* \this.number == number;
* \this.curTime == starttime;
* \this.taxiGUI == taxiGUI;
* \this.flag == new boolean[6400];
* \Thread t == new Thread(this);

\super.situation == situ;
* \super.locations == loc;
* \super.credits == credits;
* \super.cityMap == map;
* \super.startTime == starttime;
* \super.number == number;
* \super.curTime == starttime;
* \super.taxiGUI == taxiGUI;
* \super.flag == new boolean[6400];
* \Thread t == new Thread(this);

  功能bug和规格bug目前看来还没什么明显的关系。

 

  任务三:思路与体会

  这三次作业在代码上的工作量明显小了很多,主要是在规格上的练习。我也在这段时间内找过一些相对系统的工程,不得不说规格化的分析和学习真的起到了很大的作用,起码在阅读代码时真的扫清了太多的障碍,有的方法甚至只需要粗略浏览下JSF就可以轻松看出它的作用。

  然而在撰写这些规格方法时,尤其是JSF的三个要素是很考验书写者的语言概括力的,不得不说在这里真的花了很长时间,尤其是@EFFECTS,一来不能太简略,二来要能概括牵扯到的所有变化的具体情况和算法,基本上写@EFFECTS真的是最费时间的,我最担心的还是EFFECTS的bug,真的很容易被捉到破绽。

 

posted @ 2018-05-30 14:16  swordpj  阅读(126)  评论(0)    收藏  举报