Questions tagged [decoupling]

Decoupling is the reduction of dependencies between computational parts.

Coupling is a measure of dependencies between different parts of a computer program.

Decoupling is the reduction of said dependencies, in order to improve code maintainability.

The goal of decoupling is to create a loosely coupled program (also known as "low/weak coupling".

That is because a high/tight/strong coupling program is harder to change since often a change in one part of the code forces changes to other parts of the code as well, causing a ripple effect that can spread throughout the entire code base in worst case scenarios.

The benefit of a a low/loose/weak coupling program is that when a change is needed in one part of the code, it should require no change (or at the very least, as little change as possible) to the other parts of the program - thus making the maintenance of a loosely coupled program easier.

370 questions
11
votes
1 answer

MVC pattern: which is better? For views or controllers to create and reference the other?

We are making a rather large Swing application which has to implement the MVC pattern. The application currently looks like this: There are quite a few views. They are created in a hierarchical manner where one main view contains (and creates) …
Datoraki
  • 1,223
  • 13
  • 26
10
votes
4 answers

Decouple programs using queues

In his talk at the 54:53 minute mark, Rich Hickey is talking about the usage of queues as a mean to decouple dependent program parts. Can you give me an example on how to deouple the following piece of Java-pseudo-code in order to improve it's…
Matt
  • 17,290
  • 7
  • 57
  • 71
10
votes
2 answers

How to build robust data apis in clojure?

I find that my clojure apps get structurally coupled very rapidly due to the lack of a data API. I have maps with keys that have names which, if mistyped, because exceptions to be thrown or errors. I also notice that it's easy to make mistakes when…
jayunit100
  • 17,388
  • 22
  • 92
  • 167
10
votes
7 answers

How to handle or minimize tight coupling in jquery

Description By design most jquery code leads to a lot of tight coupling, e.g. selectors assume a specific structure of html var mySubnav = $("#navigation a.sub-menu"); If the corresponding html changes, for whatever reasons,
SunnyRed
  • 3,525
  • 4
  • 36
  • 57
10
votes
4 answers

REST API - how does the client know what a valid payload is to POST to the resource?

One of the goals of the REST API architecture is decoupling of the client and the server. One of the questions I have run across in planning a REST API is: "how does the client know what is a valid payload for POST methods?" Somehow the API needs to…
richard
  • 12,263
  • 23
  • 95
  • 151
10
votes
4 answers

C# Passing a collection as a collection of interfaces

I have simplified and reproduced my problem in the code below. The error that I am receiving is: Argument 1: cannot convert from 'System.Collections.ObjectModel.Collection' to 'System.Collections.ObjectModel.Collection Some background for the design…
9
votes
2 answers

Abstracting related functionality using interfaces vs tight coupling

I am trying to understand what really defines tight coupling. I have read a number of posts on the subject but one thing still doesn't sit right with me. I understand that classes should be injected into other classes using their interfaces rather…
myol
  • 8,857
  • 19
  • 82
  • 143
9
votes
7 answers

What is the golden rule for when to split code up into functions?

It's good to split code up into functions and classes for modularity / decoupling, but if you do it too much, you get really fragmented code which is also not good. What is the golden rule for when to split code up into functions?
Chetan
  • 46,743
  • 31
  • 106
  • 145
8
votes
3 answers

Should data classes be reused across layers and applications or mapped into layer specific classes?

I am creating a WPF application that uses a WCF service to interact with the data source. I use DI for both the client and the WCF server to ensure decoupled code, but I am unsure how to handle the data transfer from backend to user interface. To…
8
votes
3 answers

Abstracting the DateTime.Current dependency

Is there a nuget package, or other "standard" that wraps the hard dependency created when your code is coupled to DateTime.Now? I'm seeking guidance on this before writing my own. Albeit that it's trivial to do so, I'd rather use something that…
Chris Marisic
  • 32,487
  • 24
  • 164
  • 258
8
votes
2 answers

Layers in Domain Driven Design

In Domain-Driven Design, the domain layer is said to have no dependency on other layers, i.e. the repository interface is within the domain layer, while its implementation is at the infrastructure layer. However, the bounded context (with domain +…
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
7
votes
2 answers

C# constructor using a dynamic vs Interface as a parameter

In the benefit of creating clean decoupled code in c# I was hoping to get some feedback on using a dynamic parameter to construct objects. Typically I believe you'd create an interface and use the interface as the contract, but then you have to…
Aaron Barker
  • 706
  • 7
  • 14
7
votes
1 answer

Any examples of outstandingly well-made complete iOS apps with available source?

I'd like to look over some really good iOS apps to see how they're put together. I've specified 'complete' because I'm more interested for current purposes in strategy than tactics (but hopefully the code will be tactically well-made too).…
Cris
  • 1,939
  • 3
  • 23
  • 37
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
24 25