longtag.blogg.se

Difference between coupling and cohesion in software engineering ppt
Difference between coupling and cohesion in software engineering ppt





  1. #Difference between coupling and cohesion in software engineering ppt software#
  2. #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.

  • Store the connection retrieval and release information to a database for reporting later.
  • get stats about connection vs usage count.
  • Note that, it might look too much for a simple class like ConnectionPool but the basic intent is just to demonstrate low coupling and high cohesion with some simple example and I think should help. We can take a hypothetical scenario where we are designing an typical monitor-able ConnectionPool with the following requirements. Similarly High Coupling results in classes that are tightly coupled and changes tend not be non-local, difficult to change and reduces the reuse. Low cohesion results in monolithic classes that are difficult to maintain, understand and reduces re-usablity.

    #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.

    difference between coupling and cohesion in software engineering ppt

    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.

    difference between coupling and cohesion in software engineering ppt difference between coupling and cohesion in software engineering ppt

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







    Difference between coupling and cohesion in software engineering ppt