Cohesion and coupling examples
Hi,
Increased cohesion and decreased coupling do lead to good software design.
Decoupling allows you to change the implementation without affecting other parts of your software.
Cohesion ensures that the implementation more specific to functionality and at the same time easier to maintain.
he most effective method of decreasing coupling and increasing cohesion is design by interface.
Example of Cohesion:-
Overloading a method of a class with more functionality will result in low cohesion. Hence to avoid that break the methods in to
small chunks (packets) and perform the operations which will result in better re usability and maintainability of the code.
Example of Coupling:-
Abstraction using a interface to invoke the respective methods in an action class without directly exposing the Implementation class by creating
an instance.
Please correct me if I have gone wrong. If so please do clarify.
Thanks.