
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
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.
- Related Articles
- Difference Between Cohesion and Coupling
- Identity Cohesion vs. Role Confusion
- Make strings in array become keys in object in a new array in JavaScript?
- How to justify text in label in tkinter in Python Need justify in tkinter?
- In-service register in 8259
- NavigationView in ActionBar in Android
- JSX in depth in React.js
- deque_resize( ) in C++ in STL
- deque_rbegin( ) in C++ in STL
- deque_rend( ) in C++ in STL
- deque_insert( ) in C++ in STL
- Permutation in String in C++
- deque_emplace in C++ in STL
- deque_crend in C++ in STL
- deque_max_size( ) in C++ in STL

Advertisements