Python Turtle. Verbal Ability. Interview Questions. Company Questions. Artificial Intelligence. Cloud Computing. Data Science. Angular 7. Machine Learning. Data Structures. Operating System. Computer Network. Compiler Design. Computer Organization. Discrete Mathematics. Ethical Hacking. Computer Graphics. A good software design implies clean decomposition of the problem into modules and the neat arrangement of these modules in a hierarchy.
The primary characteristics of neat module decomposition are low coupling and high cohesion. Cohesion is a measure of functional strength of a module. A module having low coupling and high cohesion is said to be functionally independent of other modules. Functional independence means that a cohesive module performs a single function or task.
A functionally independent module has very little interaction with other modules. Coupling has also many types but usually low coupling is good for software.
Now we will see the difference between Cohesion and Coupling. Coupling is the concept of inter module. Cohesion represents the relationship within module. Coupling represents the relationships between modules. Increasing in cohesion is good for software.
Increasing in coupling is avoided for software. Cohesion represents the functional strength of modules. Coupling represents the independence among modules. Highly cohesive gives the best software.
As with coupling, having an at least passing familiarity with the different levels of Cohesion will change the way that you approach writing new classes and modules, or refactoring existing ones. For instance:. As with any principle, you want to avoid over-simplifying things. Design patterns, SOLID , and many other best practices have a lot more going on than just coupling and cohesion.
There are a lot of considerations that go into designing software. But ultimately, you have to start somewhere - and starting with a well grounded understanding of these two basic principles is an excellent foundation to build on. Personally, I've found that starting by considering things from the inside out, so to speak, and focusing first on how to make things as cohesive as possible tends to automatically reduce coupling, and to lead directly to better design decisions.
The next time you have an opportunity to design or refactor a codebase, try considering cohesion and its effect on coupling as a first principle to guide you. I bet you'll be pleasantly surprised. We're hiring! Need to upgrade your app to 6.
0コメント