The long way through Software Craftsmanship

Recognizing dependencies

Aug 8, 2015 - 1 minute read - Comments - chapterpoodrsandi-metzrubydependencyobjectquote

From the Chapter 3, Managing Dependencies, from the book Practical Object-Oriented Design in Ruby, by Sandi Metz:

An object has a dependency when it knows:

  • The name of another class. […]
  • The name of a message that it intends to send to someone other than self. […]
  • The arguments that a message requires. […]
  • The order of those arguments. […]

If an object knows any of these facts about another object, it has dependencies to the other.

This is not to say that having dependencies to others is bad, as

A single object cannot know everything, so inevitably it will have to talk to another object. Chapter 3, Managing Dependencies, Introduction

For this latter purpose, there is the section “Writing loosely coupled code”

Disclaimer about AI/GenAI

As of 2026-05-06, the text in these articles and blog entries has been written without AI/GenAI, except I sometimes use a spellchecker to fix errors. Think Word's spellchecker, not ChatGPT.

Notes, as of today (2026-05-06):

  • No code snippet has been automatically generated, nor vibe-coded, nor generated and reviewed.
  • I don’t have any article with AI contribution.

For future entries:

  • I may have used GenAI for the code in the repo. The code I exemplify/copy in the article will always be reviewed and tested, not vibe-coded. I will specify it in each snippet or at the top/bottom of the article.
  • I normally don't use it for the text contents, although if I have used it for the article text, it would be indicated as such.

Any entry before 2026-05-06 does not contain any AI/GenAI.

For more information, read the AI/GenAI Policy

Multiple return values in a Mockito Stub The language was prepared for that