Subj : What the bleep is Coupling? (was: Polymorphism sucks) To : comp.programming,comp.object From : topmind Date : Thu Jun 30 2005 06:32 pm > > >>> Copy-and-paste actually *reduces* coupling because it lets things be > >>> independent, for example. Thus, if reducing coupling is always good, > >>> then copy-and-paste is always good. > >> > >> It may appear to reduce coupling, but as has been said, it creates an > >> invisible (to the source) web of coupling that needs to be documented > >> and maintained by the developer. > > > > Yes, but that is a nebulous form of "coupling". > > Which is the worst kind! Much harder to maintain. I meant in the context of a metric for "good code" or "good design". Fuzzy metrics are not the best kind for obvious reasons. > > > Robert Martin implied that "coupling" was sure-shot metric that by > > itself would guide decisions. > > No, that was your willful misinterpretation of what he said. "Willful"? That is a rather strong accusation that frankly offends me. I swear to all known dieties there was no willful misinterpretation on my part. > There are > no sure-fire metrics, the Universal Answer to any computing question is > always, "It Depends." Robert implied it was a "universal answer", not me. I perfectly agree that there are many potential metrics, many of them conflicting such that one cannot optimize for all of them at the same time (just like most things in life). We seem to be on general agreement on this one. > > > > Note that I was not promoting copy-and-paste above. I was only > > exploring it's relationship to Robert's view of "coupling". > > Coupling is usually to be avoided as much as possible. I thought Robert agreed that some coupling is good and some is bad. Coupling is what allows one to treat things as a unit. Putting things into a suitcase is coupling, encapsulation is coupling, modules are coupling, files are coupling, database records are coupling, arrays are coupling, etc. Without coupling everything would fly apart into fine space dust. Coupling is something to manage, not to eliminate. > Invisible coupling > that depends on separate documentation or programmer memory is the worst > kind. There's nothing inconsistant with what Robert said. > Well, here are some open questions on "coupling" that seem to generate differing answers: 1. Is all coupling bad? 2. If not #1, then how does one tell good coupling from bad coupling? 3. Can all coupling be objectively measured, such as counting cross-references in programming code, or is it a kind of rough conceptual idea? (If not, "all", then what are the "kinds"?) -T- .