views:

348

answers:

12

Can we achieve 100% decoupling between components of a system or different systems that communicate with each other? I don't think its possible. If two systems communicate with each other then there should be some degree of coupling between them. Am I right?

A: 

You can achieve that. Think of two components that communicate with each other through network. One component can run on Windows while other on Unix. Isn't that 100% decoupling?

Vadmyst
Not really. They are coupled together by the protocol they use to talk to each other. While I agree this is "sort-of" 100% decoupling, I don't believe that 100% decoupling is neither possible or feasible.
Statement
+2  A: 

If components are 100% decoupled, it means that they don't communicate with each other.

Actually there are different types of coupling. But the general idea is that objects are not coupled if they don't depend on each other.

aku
A: 

At minimum, firewall protection, from a certain interface at least, needs to allow the traffic from each machine to go to the other. That alone can be considered a form of 'coupling' and therefore, coupling is inherent to machines that communicate, at least to a certain level.

Sev
A: 

This is achievable by introducing a communication interface or protocol which both components understand and not passing data directly between the components.

m_pGladiator
Yes but if we have change the protocol in the future we would need to change both components. Wouldn't this be coupling?
Daud
Well, no, as far as I understand the term "coupling". Decoupling is when the both components does not know anything for each other. They both could know something of a third component e.g. the protocol.
m_pGladiator
A: 

Well two webservices that don't reference each other might be a good example of 100% decoupled. The coupling would then arrive in the form of an app util that "couples" them together by using them both.

Coupling isn't inherently bad but you do have to make solid judgement calls about when to do it (is it only at Implementation, or in your framework itself?) and if the coupling is reasonable.

Quibblesome
+1  A: 

Right. Even if you write to an interface or a protocol, you are committing to something. You can peacefully forget about 100% decoupling and rest assured that whatever you do, you cannot just snap out one component and slap another in its place without at least minor modifications anyway, unless you are committing to very basic protocols such as HTTP (and even then.)

We human beings, after all, just LOOVE standards. That's why we have... well, nevermind.

Ishmaeel
A: 

If the components are designed to be 100% orthogonal, it should be possible. A clear separation of concerns can achieve this. All a component needs to know is the interface of its input.

The coupling should be one-directional: components know the semantics of their parameters, but should be agnostic of each other.

As soon as you have 1% coupling between components, the 1% starts growing (in a system which lasts a little longer)

However, often knowledge is injected in peer components to achieve higher performance.

xtofl
A: 

Even if two components do not comunicate directly, the third component, which uses the other two is part of the system and it is coupled to them.

@Vadmyst: If your components communicate over network they must use some kind of protocol which is the same as the interface of two local components.

EricSchaefer
A: 

That's a painfully abstract question to answer. If said system is the components of a single application, then there are various techniques such as those involving MVC (Model View Controller) and interfaces for IoC / Dependency Injection that facilitate decoupling of components.

From the perspective of physically isolated software architectures, CORBA and COM support local or networked interop and use a "common tongue" of things like ATL. These have been deprecated by XML services such as SOAP, which uses WSDL for performing coupling. There's nothing that stops a SOAP client from using a WSDL for run-time late coupling, although I rarely see it. Then there are things like JSON, which is like XML but optimized, and Google Protocol Buffers which optimizes the interop but is typically precompiled and not late-coupled.

When it comes to IPC (interprocess communications), two systems need only to speak a common "protocol". This could be XML, it could be a shared class library, or it could be something proprietary. Even at the proprietary level, you're still "coupled" by memory streams, TCP/IP networking, shared file (memory or hard disk), or some other mechanism, and you're still using bytes, and ultimately 1's and 0's.

So ultimately the question really cannot be answered fairly; strictly speaking, 100% is only attained by systems that have zilch to do with each other. Refine your question to a context.

stimpy77
A: 

It's important to distinguish between direct, and indirect components. Strive to remove direct connections (one class referencing another) and to use indirect connections instead. Bind two 'ignorant' classes with a third which manages their interactions.

This would be something like a set of user controls sitting on a form, or a pool of database connections and a connection pooling class. The more fundamental components (controls and connections) are managed by the higher piece (form and connection pool), but no fundamental component knows about another. The fundamental components expose events and methods, and the other piece 'pulls the strings'.

Steve Cooper
A: 

No, we can't. Read Joel's excellent article The Laws of Leaky Abstraction, it is an eye-opener for many people. However, this isn't necessarily a bad thing, it just is. Leaky abstractions offer great opportunity because they make the underlying platform exploitable.

Konrad Rudolph
A: 

Think of the API very hard for a very long time, then make sure it's as small as it can possibly be, until it's at the place where it has almost disappeared...

The Lego Software Process proposes this ... :) - and actually quite well achieves this...

How "closely coupled" are two cells of an organism...?

The cells in an organism can still communicate, but instead of doing it by any means that requires any knowledge about the receiving (or sending) part, they do it by releasing chemicals into the body ... ;)

Thomas Hansen