Question: Module `A` relies on module `B`, and class `C` relies on modules `A` and `B`. If I include `A` and `B` into `C`, this works, but I do not like the fact that `A` has a dependency on another module that must be mixed in along with it for it to work.

What is the "right" way to mix in modules in this situation? Should `A` mix in `B` itself? What if `C` also uses `B` directly?

```
module B
  def g
    12
  end
end

module A
  def f
    2 * g
  end
end

class C
  include A, B

  def h
    3 * f
  end
end

```

Answer: 
Nothing is wrong with writing `include` redundantly. If `A` and `C` both rely on `B`, then include `B` in both `A` and `C`.

```
module B
  def g; 12 end
  def i; 7 end
end

module A
  include B
  def f; 2 * g end
end

class C
  include A, B
  def h; 3 * f * i end
end

```

If `C` does no rely on `B`, then include `B` only in `A`.

```
module B
  def g; 12 end
end

module A
  include B
  def f; 2 * g end
end

class C
  include A
  def h; 3 * f end
end

```
Since in your case, you have no overriding methods with the same names, whatever way you mix the mixins in, the instance methods will work together as intended. You just need to make sure that they are really mixed in:

```
[ A, B ].all? { |m| C.kind_of? m } # must be true

```

So, in your case, it does not matter whether you do this

```
class C; include A, B; end

```

or this

```
class C; include B, A; end

```

or this

```
module B; include A end
class C; include B end

```

or this

```
module A; include B end
class C; include A end

```

One caveat to remind you of is, that this will not work:

```
class C; include A; end # including the module A first
module A; include B end # and trying to remix it after
c = C.new               # does not work
c.h                     # raises NoMethodError
# Modules have to have finished mixing when they are included.

```

That's all!