Coupling, with Joe Ferris

In this episode, Ben and Joe discuss several different types of coupling in code. While watching, you'll learn about three different types of coupling: Pathological Coupling, Global Coupling, and Control Coupling. You'll learn what these differen...
This is a companion discussion topic for the original entry at https://thoughtbot.com/upcase/videos/coupling-with-joe-ferris

In your example of decoupling the #print method by calling #output_to_string(@text) in the method body instead of @output_to_string(text.to_s), it feels like all you really did was move the coupling from this method to the initialize method, where presumably you’d be invoking the same #to_s method when storing the text in the @text instance variable. Am I mistaken, or is this proposed solution simply a relocation of this same notion of coupling?

Hi, I’m guessing that the second approach is better because you now depend on yourself to supply the @text instance variable. This, technically, is coupling to yourself.

On the other hand, the @output_to_string(text.to_s) depends on passing a string from any kind of object. Thus, we open more possibilities of coupling.

To summarize control coupling: a control couple is when one pers… erm class tells another class not only what to do but how to do it? :smile: