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
7
votes
5 answers

How to deal with temporal coupling?

I'm struggling because of this: My classes have some methods that have temporal coupling. This is, some method MethodA has to be invoked first to "initialize" the data that MethodB needs to work properly. I usually make the temporal coupling…
SuperJMN
  • 13,110
  • 16
  • 86
  • 185
7
votes
2 answers

How to separate Swing GUI from Business Logic when Spring etc. is not used

please be advised, this is a long post. Sorry for that but I want to make my point clear: I was wondering how to separate Swing GUI from Presentation and Business Logic for quite a long time. At work I had to implement a 3 MD Excel Export for some…
Stefano L
  • 1,486
  • 2
  • 15
  • 36
7
votes
7 answers

Does using a C++ namespace increase coupling?

I understand that a C++ library should use a namespace to avoid name collisions, but since I already have to: #include the correct header (or forward declare the classes I intend to use) Use those classes by name Don't these two parameters infer…
Mike Willekes
  • 5,960
  • 10
  • 33
  • 33
7
votes
3 answers

Reducing coupling simple example needed for beginner

Just out of college and am coming across some code where I need to reduce coupling. But I don’t understand fully all the concepts and would like a simple example to help me. To get you started I have a person class with a single field, name. I have…
Francis Rodgers
  • 4,565
  • 8
  • 46
  • 65
6
votes
2 answers

How to make objects in the deep easily configurable "from the top"?

Consider the following relation between classes: int main(int, char**) { | class Window { | class Layout { | class Box { /* Use argc/argv */ | Layout layout; | Box box; | int height, Window window; | …
Al.G.
  • 4,327
  • 6
  • 31
  • 56
6
votes
1 answer

Why is coupling to dependencies with the new keyword considered bad?

I've been using Dependency Injection for a while, and now I want to give a talk about IoC and DI to a group of new developers. I remember explaining it to one guy personally and he asked me: "Why not just use: private IMyInterface _instance = new…
5
votes
1 answer

How to properly decouple classes from frameworks (source level decoupling)

I am working on a game project using Microsoft XNA framework, although this question is a generic one that involves decoupling of classes/systems. Let's say i have a class (simplified to suit this example) as shown here: public class GameCell { …
lysergic-acid
  • 19,570
  • 21
  • 109
  • 218
5
votes
3 answers

Avoiding coupling with Strategy pattern

I am attempting to apply the Strategy pattern to a particular situation, but am having an issue with how to avoid coupling each concrete strategy to the context object providing data for it. The following is a simplified case of a pattern that…
drharris
  • 11,194
  • 5
  • 43
  • 56
5
votes
2 answers

.Net - Decoupling Unit of Work pattern for multiple ORM's

My current application structure is: Models assembly Data assembly Defines repository interfaces to be implemented by an ORM ORM assembly Implements repository interfaces from Data assembly Uses unity (IoC container) to regsister…
5
votes
4 answers

Progress bar and multiple threads, decoupling GUI and logic - which design pattern would be the best?

I'm looking for a design pattern that would fit my application design. My application processes large amounts of data and produces some graphs. Data processing (fetching from files, CPU intensive calculations) and graph operations (drawing,…
5
votes
1 answer

When is tight coupling essential or a good thing?

From all my readings and research on OO design/patterns/principles I've found that the general consensus is that loose coupling (and high cohesion) is the almost always the better design. I completely agree speaking from my past software project…
Nah
  • 331
  • 2
  • 9
5
votes
4 answers

Do events really make code decoupled?

So I am trying to use events to decouple code that I have and here is my problem: class WorldHandler { public void Notify(object sender, EventArgs e) { if (e is CameraMovedEventArgs) { // handle event } …
martynaspikunas
  • 485
  • 5
  • 15
5
votes
1 answer

Decoupling too complex javascript modules

Right now I'm developing pretty huge and complex webapp and have to deal with a huge amount of client-side js code, and to make my life easier I'm trying to decouple this code as much as I can. I was hugely inspired by Nicholas Zakas…
panfil
  • 1,489
  • 3
  • 13
  • 19
5
votes
0 answers

Is it a best practice to separate logic from presentation more?

This should be a fairly simple question, but I can't seem to find a good answer on the internet. I've been looking into Java FX and i find it interesting, although I'm having troubles being content with how I manage to separate the logic from the…
Daniel Figueroa
  • 10,348
  • 5
  • 44
  • 66
5
votes
2 answers

Decoupled architecture

I'm working on a system where I'd like to have my layers decoupled as much as possible, you know, some kind of modular application to be able to switch databases and stuff without a serious modification of the rest of the system. So, I've been…
walther
  • 13,466
  • 5
  • 41
  • 67
1 2
3
24 25