软件工程II(管理)_第三次作业(更正版)
Homework: Measuring Cohesion<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Calculate the functional cohesion measures for the following code fragment
<?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /><shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"><stroke joinstyle="miter"></stroke><formulas><f eqn="if lineDrawn pixelLineWidth 0"></f><f eqn="sum @0 1 0"></f><f eqn="sum 0 0 @1"></f><f eqn="prod @2 1 2"></f><f eqn="prod @3 21600 pixelWidth"></f><f eqn="prod @3 21600 pixelHeight"></f><f eqn="sum @0 0 1"></f><f eqn="prod @6 1 2"></f><f eqn="prod @7 21600 pixelWidth"></f><f eqn="sum @8 21600 0"></f><f eqn="prod @7 21600 pixelHeight"></f><f eqn="sum @10 21600 0"></f></formulas><path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"></path><lock v:ext="edit" aspectratio="t"></lock></shapetype><shape id="Picture_x0020_6" style="VISIBILITY: visible; WIDTH: 171pt; HEIGHT: 210pt" o:spid="_x0000_i1025" type="#_x0000_t75" alt="tu0709" o:allowoverlap="f"><imagedata src="file:///C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/msohtml1/01/clip_image001.png" o:title="tu0709"></imagedata></shape>
Answer:
Graph, under showed, showing the dependencies between the variables in the code in last example. Use solid lines for data dependencies and dashed lines for control dependencies.
<shape id="_x0000_i1027" style="WIDTH: 443.25pt; HEIGHT: 231.75pt" type="#_x0000_t75"><imagedata src="file:///C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/msohtml1/01/clip_image003.jpg" o:title="untitled"></imagedata></shape>
Total tokens = 5;
Glue tokens = 2;
Superglue tokens = 1;
Weak functional cohesion (WFC) = glue tokens / total tokens = 2/5 = 0.4;
Strong functional cohesion (SFC) = superglue tokens / total tokens = 1/5 = 0.2;
Adhesiveness = (0.4+0.2)/2 = 0.3;
Homework
1. Given the following design, indicate for the following ideas of coupling, cohesion, and abstraction whether it is desirable to have a high or low value and how this design exemplifies the term
<shape id="Picture_x0020_5" style="VISIBILITY: visible; WIDTH: 372pt; HEIGHT: 154.5pt" o:spid="_x0000_i1028" type="#_x0000_t75" alt="tu0716" o:allowoverlap="f"><imagedata src="file:///C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/msohtml1/01/clip_image005.png" o:title="tu0716"><font color="#000000"></font></imagedata></shape>
Answer:
根据上述代码可知:
由于把Course类对象直接定义为College类的成员属性,所以这两个类之间的耦合度很高。
虽然Course类中有不少成员方法,但没有一个成员方法使用到该类的成员属性,所以Course类模块的聚合度很低。
并且,这两个类中存在大量可共用的成员变量以及很多功能重复的成员方法。
建议将程序修改为:
Base.java
|
package com;
public abstract class Base
{
public String courseNum ;
}
|
Student.java
|
package com;
public class Student extends Base
{
private String stuID;
private String name;
public String getStuID() {}
public void setStuID(String stuID) {}
public String getName() {}
}
|
Course.java
|
public class Course extends Base
{
public List stuList ;
public void displayStudentsInCourse(){}
public void addStudent(Student stu){}
}
|
College.java
|
package com;
import java.util.List;
public class College
{
public List courseList ;
public void addCourse(Course course){} ;
public void displayStudent(String stuName){} ;
}
|
2. Draw scenarios for the interaction between a customer trying to buy a particular music CD with cash and a clerk in the music store. Be sure to cover all possibilities. Use the state machine model with the events being the arcs.
Answer:
<shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"><font color="#000000"><stroke joinstyle="miter"></stroke></font><formulas><f eqn="if lineDrawn pixelLineWidth 0"></f><f eqn="sum @0 1 0"></f><f eqn="sum 0 0 @1"></f><f eqn="prod @2 1 2"></f><f eqn="prod @3 21600 pixelWidth"></f><f eqn="prod @3 21600 pixelHeight"></f><f eqn="sum @0 0 1"></f><f eqn="prod @6 1 2"></f><f eqn="prod @7 21600 pixelWidth"></f><f eqn="sum @8 21600 0"></f><f eqn="prod @7 21600 pixelHeight"></f><f eqn="sum @10 21600 0"></f></formulas><path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"></path><lock v:ext="edit" aspectratio="t"></lock></shapetype><shape id="_x0000_i1025" style="WIDTH: 474.75pt; HEIGHT: 387.75pt" type="#_x0000_t75"><imagedata src="file:///C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/msohtml1/01/clip_image001.jpg" o:title="Interaction1"><font color="#000000"></font></imagedata></shape>
分享到:
相关推荐
Field-II 声场仿真文件,包含阵元设置,接收回波函数等
Altera_QuartusII_13.0_Windows_Crack破解文件 Altera_QuartusII_13.0_Windows_Crack破解文件
适合周立功及仿周立功can盒,安装容易
Quartus_II_6.0_SP1_B202_dll破解器 Quartus_II_6.0_SP1_B202_dll破解器
tutorial_quartusii_intro_verilog 介绍了verilog语法下的 quartus ii 的使用,非常详细的介绍。
USBCAN_I_II_2A_driver.bkill.com.rar
MAX_II_EPM240_570MAX_II_EPM240_570MAX_II_EPM240_570
Quartus_II_7.2_SP3破解器 #用Quartus_II_7.2_SP3破解器.exe破解C:\altera\72\quartus\bin下的sys_cpt.dll和quartus.exe文件(运行Quartus_II_7.2_SP3破解器.exe后,直接点击“应用补丁”,如果出现“未找到该文件。...
quartus_ii_80_license.rar
#首先安装Quartus II 11.0(默认是32/64-Bit一起安装): #用Quartus_II_11.0_x64破解器(内部版).exe破解C:\altera\11.0\quartus\bin64下的sys_cpt.dll和quartus.exe文件(运行Quartus_II_11.0_x64破解器(内部版)....
管家婆辉煌II_辉煌366_财贸II_财贸系列通用免狗补丁
分享一个二进制查看编辑器Hex_Editor_II_2.1.0
Quartus_II_6.0_SP1_B202_dll破解器
Matlab声学仿真软件,超声场仿真使用的
field ii 仿真工具箱 用于超声成像 可以实现激励,聚焦,声场仿真等
Quartus_II_8.0--10.0_b215破解器
Quartus_II_11.0_SP1_x86破解器(内部版).rar
uCOS_II_2.52_2.62_2.76_2.80_2.83源代码打包下载
NSGA_II多目标优化算法,用于工程优化计算,很好很强大