
- #Difference between coupling and cohesion in software engineering ppt software#
- #Difference between coupling and cohesion in software engineering ppt code#
And the ConnectionPool will iterate through these listeners and notify them of connection get and release events and allows less coupling. Instead to reduce the coupling we could introduce a ConnectionListener interface and let these two classes implement the interface and let them register with ConnectionPool class. If we look at the above diagram although it supports high cohesion, the ConnectionPool is tightly coupled with ConnectionStatistics class and PersistentStore it interacts with them directly. To demonstrate Low coupling we will continue with the high cohesion ConnectionPool diagram above. With high cohesion we can assign these responsibility across the classes and make it more maintainable and reusable. We can see that this single class is responsible for connection management, interacting with database as well maintaining connection stats. With low cohesion we could design a ConnectionPool class by forcefully stuffing all this functionality/responsibilities into a single class as below.
#Difference between coupling and cohesion in software engineering ppt software#
And while designing the systems it is recommended to have software elements that have High cohesion and support Low coupling. The software element could be class, package, component, subsystem or a system. Good software design has high cohesion and low coupling.Ĭohesion is an indication of how related and focused the responsibilities of an software element are.Ĭoupling refers to how strongly a software element is connected to other elements.
#Difference between coupling and cohesion in software engineering ppt code#
High coupling would make it difficult to change and maintain your code since classes are closely knit together, making a change could require an entire system revamp.

For low coupled classes, changing something major in one class should not affect the other. only methods relating to the intention of the class.Įxample of Low Cohesion: -Įxample of High Cohesion: -Īs for coupling, it refers to how related or dependent two classes/modules are toward each other. High cohesion means that the class is focused on what it should be doing, i.e. Low cohesion would mean that the class does a great variety of actions - it is broad, unfocused on what it should do.


Cohesion refers to what the class (or module) can do.
