I’ve received a few questions about Implicit and Explicit Coupling via channels other than the comments here. So in this and the next couple of articles I’m going to have a go at answering them…
Recently on a Slack channel somewhere in Manchester, someone asked:
I've always known the terms loose and tight coupling, is there any difference to implicit/explicit?
I was in the car somewhere and didn’t see the message for a few hours, but in the meantime Ross had replied:
Implicit coupling tends to reveal itself at runtime, explicit can be found at compile time
Up to now in these articles I’ve been deliberately vague about this. For example, in Coupling Between Types — A Retrospective I wrote:
if a change to something elsewhere in the codebase could cause this function to misbehave, that possibility should be obvious locally, within this function itself
The key word here is “obvious”, and I’m not ready yet to define precisely what I mean by it. In part, that’s why I’m writing this newsletter. I want to use these articles — and your feedback — to explore the concept of Implicit Coupling. I have no idea yet whether it will turn out to be useful or understandable, and that’s why we’re here.
As things stand right now, there is one very good reason why I wouldn’t want to directly associate Explicit Coupling with compile time: There’s no stable notion of “compile time” across the whole scope I want to consider. For example, with a melting ice compiler such as that employed for Eiffel, exactly when is the code compiled? Or what about coupling in CSS, or between CSS and HTML?
Nevertheless, Ross has a valid point: I’m proposing a new(-ish) way to think about the biggest problem in managing software maintainability, and yet I refuse to define my terms!
And that’s because there’s a second — and more compelling — reason that I don’t want to correlate explicit coupling with compile time: we haven’t yet explored enough examples to demonstrate whether such a correlation would be warranted.
My hope with these articles is that a deeper understanding of Implicit Coupling can be teased out by exploring examples, and until we’ve looked at quite a lot of them I don’t believe it will be possible to generalise. There’s a hand-wavy section towards the end of the draft table of contents in If this were a book... that talks about creating a catalogue of examples of implicit coupling in many different programming technologies. I believe that catalogue must be our starting point. It must be developed and explored as our first activity, before anyone can say whether Implicit Coupling is going to turn out to be a useful idea, and before anyone can look for the presence — or absence — of patterns that might lead us to more general and abstract statements.
It also seems possible that as we explore the topic we’ll discover that tools could be written to help us to “see” Implicit Coupling. As (I hope) I explained in Discount Rules, some Reflection, any such tool would have to be provided with an omniscient view of the code, and so any coupling discovered would be a function of the horizon of any such view. But again, we’ll need to explore the space in detail before any such opportunities present themselves as being possible or impossible.
As Brian Marick says: “An example would be handy right about now”. By creating that catalogue of examples — and counterexamples — I hope we can “test drive” into existence some kind of model of Implicit Coupling that will turn out to be useful.
So for now I’m happy to continue saying that “explicit” is in the eye of the beholder.
Hello Kevin, congratulations for the initiative.
My thoughts: I think that "explicitness" is really powerful concept, and a key one in software design.
The relation between "being explicit" and coupling, as you clearly showed, is very important, but when I think also to "intention revealing interfaces", "good names", "ubiquitous language" et cetera, I feel that concept could be further extended and explored. The simple hint "the code should be explicit in what it does" is able to bring you in favouring good names for classes/methods, immutability over mutability, avoiding side-effects, and so on. "To be explicit" looks to me a powerful driving principle.
There are currently, in my opinion, too much so called "principles" in software design (some of them being actually a re-formulation of others, ex.: the SRP is just a re-statement of 'separation of concerns and cohesion' for me), and I think they should be reduced to a small set of principles that are really "fundamentals".
I'm thinking that explicitness could be the base for such a principle, able to sum and encompass some others. I really like the idea. What do you think?