您的位置:首页 > 其它

软件工程II(管理)_第三次作业(更正版)

2008-11-09 23:19 232 查看
软件工程II(管理)_第三次作业(更正版)


Homework: Measuring Cohesion

Calculate the functional cohesion measures for the following code fragment

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.

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



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:



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: