What is module dependency? I see that modules can have dependencies on other modules.

Why is this, and how might I use this in my own custom module development?
Module dependency can be defined as follows.

If a module A requires that module B to be enabled before the module A is enabled then, module A is dependent on module B.

In other words, if module A uses some of the functions that are available or defined in module B then it becomes mandatory to enable module B prior to enabling of module A, as not doing so may result in a "call to undefined function error"

Dependencies are very useful as it may save lot of your development time by allowing you to use functions that are already available in other modules, instead of rewriting the function in your module.

A module's dependencies are mentioned in the module's .info file. Following is an example from the forum module


name = Forum
description = Provides discussion forums.
dependencies[] = taxonomy
dependencies[] = comment
package = Core
version = VERSION
core = 7.x
files[] = forum.test
configure = admin/structure/forum
stylesheets[all][] = forum.css


The lines : 


dependencies[] = taxonomy
dependencies[] = comment


declare or make the forum modules to be dependent on the 'taxonomy' and 'comment' modules. We can also say that the 'taxonomy' and 'comment' modules are the dependencies for the forum module.

In your module A you can add dependencies for module B and module C by adding the following lines in the a.info file of your module A .


dependencies[] = b
dependencies[] = c