Question: a. What should be the goal while designing a subsystem in terms of Cohesion and Coupling? Discuss briefly. b. The following Employee class has some
a. What should be the goal while designing a subsystem in terms of Cohesion and Coupling? Discuss briefly.
b. The following Employee class has some public data members: a String data member (Name), getter (getName) and setter (setName) methods, which implement some checks to ensure;
Name cannot be set to a null value and
Name can be accessed only when its value is not null
Identify the coupling behavior for the following program and justify your answer.
public class Employee {
public String Name;
public String getName(){
if(Name==null)
return "Not initialized";
else
return Name;
}
public void setName(String Nm){
if(Nm!=null)
this.Name=Nm;
else
System.out.println("Name cannot be initialized to a null");
}
}
public class Manager {
public static void main(String[] args) {
Employee emp=new Employee();
emp.Name=null;
System.out.println("Name is "+ emp.Name);
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
