Tight coupling is when a group of classes are highly dependent on one another. This scenario arises when a class assumes too many responsibilities, or when one concern is spread over many classes rather than having its own class. Loose coupling is achieved by means of a design that promotes single-responsibility and separation of concerns. A loosely-coupled class can be consumed and tested independently of other (concrete) classes. Interfaces are a powerful tool to use for decoupling. Classes can communicate through interfaces rather than other concrete classes, and any class can be on the other end of that communication simply by implementing the interface. Example of tight coupling: class CustomerRepository { private readonly Database database; public CustomerRepository(Database database) { this.database = database; } public void Add(string CustomerName) { database.AddRow("Customer", CustomerName); } } class Database { public void AddRow(string Table, string Value) { } } Example of loose coupling: class CustomerRepository { private readonly IDatabase database; public CustomerRepository(IDatabase database) { this.database = database; } public void Add(string CustomerName) { database.AddRow("Customer", CustomerName); } } interface IDatabase { void AddRow(string Table, string Value); } class Database : IDatabase { public void AddRow(string Table, string Value) { } } | 0 |
By: [email protected] On: Sat Jun 22 08:43:21 EDT 2013 0 147 0 | 147 |
Are You Satisfied :3Yes2No |
loose coupling (or loosely coupled) is a type of coupling that describes how multiple computer systems, even those using incompatible technologies, can be joined together for transactions, regardless of hardware, software and other functional components. Loosely coupled systems describe those that work on an exchange relationship where little input is needed from each of the additional systems. In a loosely coupled system hardware and software may interact but they are not dependant on each other to work. tight coupling (or tightly coupled) is a type of coupling that describes a system in which hardware and software are not only linked together, but are also dependant upon each other. In a tightly coupled system where multiple systems share a workload, the entire system usually would need to be powered down to fix a major hardware problem, not just the single system with the issue. | 0 |
By: [email protected] On: Sat Jun 22 08:52:47 EDT 2013 0 392 0 | 392 |
Are You Satisfied :1Yes1No |