Skip to main content

Cohesion

Muhammad FurqanLess than 1 minute

Introduction

In the context of coding, cohesion refers to the degree to which the elements within a piece of software, such as functions, classes, and modules, work together to form a unified and coherent whole. In other words, cohesion is the logical and functional tying together of software so that it is easy to understand, maintain and extend. It is the logical relationship between the functions and objects within a piece of software.

High cohesion means that the functions and objects within a module have a strong, single purpose and work together to achieve that purpose. Low cohesion means that the functions and objects within a module have multiple, unrelated purposes and do not work well together. High cohesion is generally considered to be a best practice in software design, as it leads to more maintainable and extensible code.