examine the goals of coupling and cohesion and the approaches to design you use
ID: 3532864 • Letter: E
Question
examine the goals of coupling and cohesion and the approaches to design you use to achieve those goals for your design. Using your readings from this unit and the Internet, examine the concepts of coupling and cohesion as they are defined and used in both an object-oriented design approach and in a structured design approach.
Thinking as a systems analyst, which approach best enables you to design a system that meets the goals of low coupling and high cohesion? Why? Support your position with examples (e.g., functional, sequential, communicational, or iterative).
by puting the Reference with your answer
Explanation / Answer
I'll try to explain the concepts of Coupling and Cohesion, please ask questions, if you have any doubts :
Lets take two classes A and B
Now, A and B will be called highly coupled if the existence of one of them depends on the other. i.e.
If one of the class's constructorhas the Reference to the Object of other class. :
public class A
{
private B b;
public A(B b)
{
this.b=b;
}
}
public class B
{
......
}
Cohesion,on the other hand is the degree to which a class is dependent on itself. i.e. it can exist without depending on other classes :
public class A
{
public A()
{
//do something
}
public showB(B b)
{
System.out.println(b.toString());
}
}
public class B
{
public B()
{
//do something
}
public String toString()
{
return "this is an Object of type B";
}
}
Now Lets come to why a System should have low Coupling and High Cohesion :
Suupose, you are designing a software which uses Different Layers of Modules, that work together to achieve the goal. Now after a year or so, one of your module got outdated. What would you do now ?
Ofcourse go for a Change in your code !!
But, there is a problem. Your code is of thousands of lines and all your classes/modules are tightly coupled. i.e. if you try to change any class/module, your whole application would collapse.
To avoid such scenarios, one must ensure that the modules/classes are seperated logically, so that when time comes, they can be used as Plug n Playmodules.
Hope it helped :)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.