- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Cohesion in C#
Cohesion in C# shows the relationship within modules. It shows the functional strength of the modules. The greater the cohesion, the better will be the program design.
It is the dependency between the modules internal elements like methods and internal modules. High cohesion will allow you to reuse classes and method.
An example of High cohesion can be seen in System.Math class i.e.it has Mathematical constants and static methods −
Math.Abs Math.PI Math.Pow
A class that does a lot of things at a time is hard to understand and maintain. This is what we call low cohesion and should be avoided. If a class will provide functions for email, print, copy, etc time, then it would be hard to maintain and reuse.
Always try to achieve strong i.e. high cohesion in your code.
Advertisements