I have been reading up on the seminal and excellent book Code Complete. It discusses about the various kinds of couplings that can happen between modules(which may be classes as well as methods):

  1. Simple-data-parameter-coupling
  2. Simple-object-coupling
  3. Object-parameter-coupling
  4. Semantic coupling

The book has to say this about object-parameter coupling :

Two modules are object -parameter coupled to each other if Object1 requires Object2 to pass it an Object3. This kind of coupling is tighter than Object1 requiring Object2 to pass it only primitive data types because it requires Object2 to know about Object3.

What is the author trying to mean here?

1 Answer 1


an example: imagine object1 requires object2 to pass it a time-stamp:

  1. case 1 (tightly coupled):
    object2 passes a custom Time-instance (object3):
    therefore object1 must know how to extract the necessary data form this object

  2. case 2 (less coupled):
    object2 passes seconds_since_epoch (integer), object does not have to know the internals of another object.

  • but this has the downside that you need to pass a lot of parameters (imagine a timestamp object containing a lot of attributes)
    – Geek
    Mar 2, 2013 at 15:26
  • @Geek: yep, it is a trade-off. Using (more) primitive parameters may be the better alternative if object1 and object2 are written in different languages or using different technologies, and the "bridge technology" for passing that gap can handle primitive data types easier than user-defined data types. For example, if you have library written in C, and want to use it from some higher level language, the primitive data types are often the "least common denominator".
    – Doc Brown
    Mar 2, 2013 at 22:06
  • I don't own the book, so I'm asking here: is there any explanation in the book as to why case 1 is considered to be more tightly coupled? In case 1 object1 needs to know the internals of object3, in case 2 object2 needs to know the internals of object1 (otherwise it wouldn't know whether to pass seconds_since_epoch or milliseconds_since_january_first_2000). So, the coupling seems to be about the same. Mar 3, 2013 at 2:30
  • @JörgWMittag, in both cases the caller has to know the signature. so, your case 2 is implicit in your case 1, which leaves us in the original situation with the question if there is a third object at all or not.
    – kr1
    Mar 4, 2013 at 7:57
  • @kr1: My point is that in case 2, the caller needs to not only know the signature (e.g. int), but also how the callee is going to interpret that int, IOW the internal representation of time inside the callee, whereas in case 1 that internal representation is encapsulated inside object 3 and thus completely irrelevant. Representation Agnosticism through Behavorial Abstraction is the very core of OO, whereas McConnell seems to argue for Primitive Obsession. Mar 4, 2013 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.