--- Video Title: Cohesion and Coupling Description: Cohesion and Coupling Watch more Videos at https://www.tutorialspoint.com/videotutorials/index.htm Lecture By: Mr. Arnab Chakraborty, Tutorials Point India Private Limited --- We are going to discuss a very interesting topic that is cohesion and coupling. So, let us discuss on them into more details and their respective categories. When a software program is modularized, the tasks are divided into several modules based on some characteristics. In the previous video, we have discussed modularization. So, you can watch that one because this video is a continuation of the previous one. So, here we can divide a software, a large software is very difficult to handle and deal with. So, that is why a software can be considered as a collection of modules. And these modules can operate in sequence, can operate in parallel and each and every module must have some dedicated purposes. So, as we know that modules are set of instructions put together in order to achieve some task. To execute one task, we can consider one module which is responsible for the task execution. So, they are though considered as a single entity, but may refer to each other on work together. Always we should try to feel that this modules are working in an having no interdependence in between. But sometimes one module can access the other module can call the other module for execution. There are measures by which the quality of a design of modules and their introductions among them can be measured. And these measures are called coupling and cohesion. So, how the modules are interacting with each other and how the statements and instructions which are residing within one module. So, how they are correlated, how they are related, so that will be handled. The measurements will be done in coupling and cohesion. So, at first we are going to discuss cohesion, then we shall go for the coupling. So, cohesion is a measure that defines the degree of interdependability within elements of a module. The greater the cohesion, better is the program design. So, what is a cohesion? We know that a module will be consisting of multiple number of instructions. So, how these instructions are having the interdependability? So, whether they are very much cohesive or they are not related to each other. So, that is the measure of cohesion. And when a module is having high cohesion, it indicates that the software design quality is good enough. So, there are seven types of cohesion. So, let first one we are considering that is co-incidental cohesion. It is unplanned and random cohesion, which might be the result of breaking the programs into smaller modules for the sake of modularization. So, because it is unplanned, it may serve confusion. So, it may serve confusion to the programmers and is generally not accepted. So, in case of coincidental cohesion, actually let us suppose we are having a long code. We have divided this code arbitrarily into certain modules to implement modularization in our code. So, the instructions which will be coming under one module, they are co-incidental. So, that is why they are not properly very much related to each other. So, this sort of cohesion will produce some confusion in the respective developers or in the respective coders mind. Let us suppose, we are going for the next cohesion that is the logical cohesion. When logically categorized elements are put together into a module, it is called a logical cohesion. So, when some instructions statements are logically related, and in that case, if you can put them into one module, then in that case, we can say that, that very module is having the logical cohesion. So, next one is our temporal cohesion. When elements of modules are organized such that, they are processed at a similar point of time, these things will be known as the temporal cohesion. That means, when the elements of a module are organized in such way that, they will be executing or they will be processed at a similar point of time. So, that is why the name is temporal cohesion. Then you can say that, this module is exerting temporal cohesion. Next one is our procedural cohesion. So, procedural cohesion means, when elements of modules are grouped together, which are executed sequentially in order to perform a task, and then it is called procedural cohesion. So, to implement one task in the software, if you develop one module, that means, the purpose of the module is that, if the module gets executed, the task will get completed, the task is getting accomplished, then you can say that, that very module is having procedural cohesion. Next one is the communicational cohesion. So, when elements of modules are grouped together, which are executed sequentially, and work on same data, there is an information. So, it is called communicational cohesion. So, whenever instructions are getting executed, and they are working on the same set of data, then you can say that, this particular group of instructions, so are having this communicational cohesion. So, let me repeat it once again. When elements of module are grouped together, which are executed sequentially, one after another, so that is another very important point. So, instructions are getting executed sequentially, linearly, one after another, and work on the same data set, that is the information, then you can say that, this particular module is showing communicational cohesion. Next one is the sequential cohesion. When elements of module are grouped, because the output of one's element solve as the input to another one, and so on, this particular output of one element will be the input of the next element. If it has been, if it is been continued, then you can say that, this module is showing sequential cohesion. The last one is our functional cohesion. It is considered to be the highest degree of cohesion, and it is highly expected. Elements of module in functional cohesion are grouped, because they all contribute to a single when defined function. So, it can be reused again and again. So, that means, whenever a particular module is trying to implement one function, then you can say that, that module is having functional cohesion. We know that, a software will have multiple different functional requirements, multiple different functions are to be carried out. So, if a module, which is dedicated to execute one function of the software, then you can say that, the module is having functional cohesion, and it is the highly expected, that the module should have a functional cohesion. So, in this way, we have discussed all the cohesion types. Now, let me discuss coupling. So, coupling is a measure that defines a level of interdependability among the modules of a program. So, cohesion was dealing with, within a single module. So, how these instructions are getting related? So, whether it is coincidental, temporal, or say procedural. So, in this way, we are having multiple different types are there. So, that is our cohesion. Now, we are having multiple, say we are having two modules. So, what are the interdependability between these two, that will be handled by the coupling. So, it tells at what level the modules interfere and interact with each other, and the lower the coupling, better the program. So, always remember this very statement, that is cohesion higher expected, and coupling lower between the modules expected. So, if you find that there is one software design, where the modules are having, modules are highly cohesive, and modules are in between modules, the coupling is very less. That means, it is a good software design. So, there are five levels of coupling. Let me discuss them one by one. First one is the content coupling. So, when a module can directly access or modify or refer to the content of another module, then it is called content coupling. Next one is the common coupling. When multiple modules have read and write access to some global data, it is called common or global coupling. When multiple modules can access, can perform read and write operations on some set of global data, then you can say that these two modules are having the coupling, known as a common coupling. Next one is the control coupling, two modules are called control coupled if one of them decide the function of the other module or changes its flow of execution. So, one module is deciding Meaning that how the other module will have its flow of execution. So, that is known as our control coupling. So, let us go for the last but one that is a stamp coupling. When multiple modules share the common data structure and work on different part of it is called the stamp coupling. So, when multiple modules are working on the same data structure, let it be the say binary tree. So, this is a data structure. So, multiple modules are working We are back. We are back. We are back. We are back. We are back. We are back. The ccet case case case case case case case case case case case case case case case case case case case case case case case case case case case case case case case case case case case case case case case case case case case Highest cohesion within a model will be considered as the best design. So, in this particular session, we have discussed what is cohesion, what is coupling. These are very important questions that come in the technical round, in the interview and also in our theory exams. Thanks for watching this video.