Coupling in C#

CsharpProgrammingServer Side Programming

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.

Published on 17-Sep-2018 09:15:54