What is a dependency

As you can infer from its English meaning, the word dependency indicates that a part of code depends on some other part of code. It could be either loose coupling (where the code depends on an abstract class or interface) or strong coupling (where the code depends on a concrete class). I believe examples provide a better understanding so lets see an example.

Snippet 1

The function doSomeWork uses some functionality from class B. So class A has a dependency on class B. If class B required some constructor parameters, it would become the responsibility of doSomeWork to provide those parameters.

Snippet 2