Questions tagged [coupling]

197 questions
345
votes
16 answers

What is the difference between loose coupling and tight coupling in the object oriented paradigm?

Can any one describe the exact difference between loose coupling and tight coupling in Object oriented paradigm?
Jim
  • 4,639
  • 5
  • 27
  • 31
70
votes
6 answers

Coupling, Cohesion and the Law of Demeter

The Law of Demeter indicates that you should only speak to objects that you know about directly. That is, do not perform method chaining to talk to other objects. When you do so, you are establishing improper linkages with the intermediary…
Bradley Mazurek
  • 941
  • 9
  • 9
38
votes
11 answers

How to solve the violations of the Law of Demeter?

A colleague and I designed a system for our customer, and in our opinion we created a nice clean design. But I'm having problems with some coupling we've introduced. I could try to create an example design which includes the same problems as our…
Davy Landman
  • 15,109
  • 6
  • 49
  • 73
37
votes
5 answers

Cohesion and Decoupling, what do they represent?

What are Cohesion and Decoupling? I found information about coupling but not about decoupling.
dbtek
  • 928
  • 2
  • 12
  • 14
30
votes
3 answers

Separation of game and rendering logic

What is the best way to separate rendering code from the actually game engine/logic code? And is it even a good idea to separate those? Let's assume we have a game object called Knight. The Knight has to be rendered on the screen for the user to…
Kasper Holdum
  • 12,993
  • 6
  • 45
  • 74
24
votes
5 answers

What is the difference between afferent couplings and efferent couplings of a class?

Code quality metric tool like Sonar does provide the ability to drill down to a class and find out the number of: Afferent (incoming) couplings Efferent (outgoing) couplings What are these two parameters? Can you please describe with a simple…
Geek
  • 26,489
  • 43
  • 149
  • 227
22
votes
6 answers

How should I inherit IDisposable?

Class names have been changed to protect the innocent. If I have an interface named ISomeInterface. I also have classes that inherit the interface, FirstClass and SecondClass. FirstClass uses resources that must be disposed. SecondClass does…
Andy West
  • 12,302
  • 4
  • 34
  • 52
13
votes
2 answers

Model Using Modules in Rails Application

I have a model that requires loading external data from an auxiliary source. A number of web services exist that my model can fetch the data from (swappable), but I don't want to create code that will make it difficult to change services (costs…
Kevin Sylvestre
  • 37,288
  • 33
  • 152
  • 232
12
votes
10 answers

Loose Coupling vs. Information Hiding and Ease of Change

I'm just reading Code Complete by Steve McConell and I'm thinking of an Example he gives in a section about loose coupling. It's about the interface of a method that calculates the number of holidays for an employee, which is calculated from the…
cretzel
  • 19,864
  • 19
  • 58
  • 71
11
votes
5 answers

A python web application framework for tight DB/GUI coupling?

I'm a firm believer of the heretic thought of tight coupling between the backend and frontend: I want existing, implied knowledge about a backend to be automatically made use of when generating user interfaces. E.g., if a VARCHAR column has a…
Troels Arvin
  • 6,238
  • 2
  • 24
  • 27
11
votes
6 answers

Best practices for creating libraries that use .NET namespaces

Is it bad practice to write a library that defines an interface dependent on another library? I know tight coupling is bad, but does this still apply when using .NET classes? For example, in .NET, if I have a library that returns a Color object, it…
DanDan
  • 10,462
  • 8
  • 53
  • 69
8
votes
10 answers

Object-oriented Paradigm Question

Even though I've been programming for quite a while now, when it comes to coupling objects I always seem to bang my head against the wall so I'm wondering if anyone has any resources or golden rules I can follow. Let me give a small example, in no…
David Titarenco
  • 32,662
  • 13
  • 66
  • 111
8
votes
3 answers

CBO coupling between object

I don't understand what "CBO-Coupling between object classes" really means. The definition I found is so short that I think I'm missing something, so it would be great if you help me with an example. Here is the definition I found: "The coupling…
Abdelaziz Dabebi
  • 1,624
  • 1
  • 16
  • 21
8
votes
5 answers

Coupling is too high - how to design this class better?

Running FxCop on my code, I get this warning: Microsoft.Maintainability : 'FooBar.ctor is coupled with 99 different types from 9 different namespaces. Rewrite or refactor the method to decrease its class coupling, or consider moving the…
Judah Gabriel Himango
  • 58,906
  • 38
  • 158
  • 212
7
votes
9 answers

Decoupling vs YAGNI

Do they contradict? Decoupling is something great and quite hard to achieve. However in most of the applications we don't really need it, so I can design highly coupled applications and it almost will not change anything other than obvious side…
dr. evil
  • 26,944
  • 33
  • 131
  • 201
1
2 3
13 14