If our class depends upon other classes to complete its operations, then these other classes are dependencies for our class. Our class can have these dependencies as implicit or explicit dependencies. What does this mean? What effect does it have on our application design? Let’s try to find answers to similar questions.


Implicit Dependencies

The dependencies are implicit for a class, if they exist only in the code within that class, and not in its public interface. Therefore, while instantiating our class, we will not be aware of any dependency that our class may have, to perform its operations. Consequently, our code may fail during execution.

Classes with implicit dependencies cost more to maintain than those with explicit dependencies. Also, they are more difficult to test because of their tight coupling with the collaborators. And the tight coupling among the classes and their collaborators, result in more rigid and brittle designs.




As we can see, the Commerce class is tightly coupled with the PaymentProcessor and CurrencyConverter. Also, at the time of object creation for Commerce class, we can not judge what all collaborators it is going to use. Further, we will see how we can refactor this code in order to achieve loose coupling.


Explicit Dependencies

Being explicit about its dependencies means, that a class exposes all its class-level dependencies in its constructor. However, more local ones may appear as method parameter list. It is due to the explicit declaration, that we are aware of all dependencies a class has, at the time of its object construction.

An explicit dependency is often declared as an interface in the class constructor. Consequently, the dependency can be easily swapped out with its other implementations, whether in production or during testing or debugging. This makes them much easier to maintain and far more open to accept any change.



In this example, the Commerce class exposes all its required collaborators in its constructor. As a result, we have a loosely coupled application. Moreover, we now have the freedom to choose among different implementations of these interfaces required by the Commerce class. Consequently, the application is now easy to maintain, test and expand.


Maryam Stageman · October 25, 2018 at 9:35 am

Perfect just what I was looking for! .

Kristal · October 30, 2018 at 9:56 pm

Howdy! This is kind of off topic but I need some advice
from an established blog. Is it hard to set up your own blog?
I’m not very techincal but I can figure things out pretty
quick. I’m thinking about creating my own but I’m not sure where to start.
Do you have any ideas or suggestions? Thank you

    Gaurav Gahlot · November 2, 2018 at 7:30 am

    Hi Kristal!

    First of all, congratulations for thinking and planning to start your own blog. This certainly makes you stand out of the crowd.
    Starting a blog or website is not that difficult. You need to follow certain steps and you are ready to share your content.

    You need to do the following:

    1. Decide whether you want to build you website from scratch or you would prefer to use a CSM like WordPress. I’m using WordPress. This allows you to focus on your content, rather than maintaining the website.
    2. Based on your selection above, choose a web host that meets your requirements.
    3. Find a domain name that best define your blog or website. Register your domain with host. A few famous hosts are GoDaddy, HostGator, and A2A Hosting.
    4. Select a hosting plan that best suits your needs. As a beginner you can start with a basic plan and upgrade in future as traffic grows.
    5. Setup the website, install plugins and softwares as required (completely derived from your selection at point 1)
    6. Woollaah, you have your own website now!

    These steps may seem to be difficult or time taking, but let me tell you they are not. And all the effort is worth it.

    Please do let me know if you need any other detail. And once you have setup your blog DO share the link. I’ll be more than happy to see it.

    Thank you! All the best!

Gaurav Gahlot · November 13, 2018 at 8:06 am

Thank you Wayne! I’m really glad you found it useful. 🙂

Compare hosting · November 15, 2018 at 5:36 pm

Hi everyone Good day! I simply would like to give you a huge thumbs up for your great info you have got right here on this post. I am returning to your site for more soon. many thanks

Kris Forkum · November 22, 2018 at 11:30 pm

I enjoy what you guys are up too. This kind of clever work and coverage! Keep up the great works guys I’ve included you guys to blogroll.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.