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
630
votes
15 answers

Type List vs type ArrayList in Java

(1) List myList = new ArrayList(); (2) ArrayList myList = new ArrayList(); I understand that with (1), implementations of the List interface can be swapped. It seems that (1) is typically used in an application regardless of need…
kji
  • 6,681
  • 3
  • 18
  • 7
134
votes
8 answers

Best practice for embedding arbitrary JSON in the DOM?

I'm thinking about embedding arbitrary JSON in the DOM like this: This is similar to the way one might store an arbitrary HTML…
Ben Lee
  • 52,489
  • 13
  • 125
  • 145
98
votes
3 answers

When should I use jQuery deferred's "then" method and when should I use the "pipe" method?

jQuery's Deferred has two functions which can be used to implement asynchronous chaining of functions: then() deferred.then( doneCallbacks, failCallbacks ) Returns: Deferred doneCallbacks A function, or array of functions, called when the Deferred…
hippietrail
  • 15,848
  • 18
  • 99
  • 158
97
votes
4 answers

Difference between "Inversion of Control", "Dependency inversion" and "Decoupling"

I'm reading theory about dependency inversion and decoupling and I can't see the difference between the two. Dependency inversion talks about decoupling functional components so that higher level components don't depend on lower level…
Robert Koritnik
  • 103,639
  • 52
  • 277
  • 404
71
votes
4 answers

Managing resources in a Python project

I have a Python project in which I am using many non-code files. Currently these are all images, but I might use other kinds of files in the future. What would be a good scheme for storing and referencing these files? I considered just making a…
Ram Rachum
  • 84,019
  • 84
  • 236
  • 374
51
votes
6 answers

Best practice for Android MVVM startActivity

I am building an Android App using MVVM and DataBinding. And I have a function inside my ViewModel that starts an Activity. Is it okay to have an onClick call inside a ViewModel? Like this. public class MyViewModel { public void onClick(View…
Felipe Kenji Shiba
  • 704
  • 1
  • 6
  • 10
38
votes
6 answers

Functional programming and decoupling

I'm your classic OOP developer. However since I discovered purely functional programming languages I've been ever intrigued to the why since OOP seemed to solve most business cases in a reasonable manner. I've now come to the point in my software…
Bjarke Sporring
  • 528
  • 5
  • 7
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
31
votes
3 answers

Stairway pattern implementation

I came across "Stairway" pattern description in the "Adaptive code via C#" book and I don't really understand how this is supposed to be implemented: (source) So I have client assembly: using ServiceInterface; namespace Client { class Program …
d453
  • 519
  • 6
  • 10
31
votes
8 answers

How is JavaScript library bloat mitigated with Web Components?

As someone who has tried to find a way to help content authors develop and maintain big web sites by creating (HTML) components for years, I'm really excited to see web components gaining tracction at w3c, google and mozilla. But it seems to me…
30
votes
3 answers

How do you use python-decouple to load a .env file outside the expected paths?

I'm forced to keep my .env file in a non-standard path outside the root of my project (in a separate directory altogether). Let's say I have my Django project in /var/projects/my_project, though I have my .env file in /opt/envs/my-project/.env where…
John Adjei
  • 1,483
  • 2
  • 14
  • 19
20
votes
4 answers

What does decoupling two classes at the interface level mean?

Lets say we have class A in package A and class B in package B . If object of class A has reference to class B, then the two classes are said to have coupling between them. To address the coupling, it is recommended to define an interface in…
Sarit Adhikari
  • 1,344
  • 2
  • 16
  • 28
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
4 answers

How does ETL (database to database) fit into SOA?

Lets imagine, that our application needs ETL (extract, transform, load) data from relation database to another relation database. Most simple (and most performance, IMHO) way is to make link between databases and write simple stored procedure. In…
nikolobok
  • 155
  • 1
  • 7
12
votes
8 answers

Why do we pass objects rather than object members to functions?

I have a method FOO() in class A that takes as its arguments input from data members of class B among other things (let's say they are two floats and one int). The way I understand this, it is generally better to implement this with something…
user1790399
  • 220
  • 2
  • 11
1
2 3
24 25