Coupling in C#


Coupling shows the relationship between modules in C# or you can say the interdependence between modules.

There are two types of coupling i.e tight and loose coupling.

Loose Coupling

Loose coupling is preferred since through it changing one class will not affect another class. It reduces dependencies on a class. That would mean you can easily reuse it.

Writing loosely coupled code has the following advantages −

  • One module won’t break other modules
  • Enhances testability
  • Code is easier to maintain
  • Gets less affected by changes in other components.

Tight Coupling

In Tight Coupling, the classes and objects are dependent on each other and therefore reduce re-usability of code.

Updated on: 14-Apr-2020

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements