DEV Community

Graham Cox
Graham Cox

Posted on

On Embeddable Dependencies

I'm a big fan of automated testing, and of self contained development systems.

In part this comes from having suffered through the lack of this in the past. Having to depend on systems that are hosted elsewhere and managed by other groups can be an exercise in frustration. And, even worse, makes it impossible to develop in an offline environment.

As such, I've become a huge fan of what I call Embeddable Dependences. This doesn't mean that the dependencies are embedded in your application - though that is an option. It means they are embedded in your development process. It means that you can start up a clean database that mirrors the production setup as part of running acceptance tests, or in order to run the system locally. It means having alternative versions of third party REST APIs available to test against. In short, it means you can run your application in both acceptance test mode and local deployment mode even when you're not online.

So, how do I achieve this? It varies from project to project, and from dependency to dependency. You need to do what makes the most sense for your scenario.

When I'm developing in node, I generally use Docker from some Grunt tasks. I can then start up any application that has a Docker image available really trivially.

When I'm developing in Java I can use Docker as well - though I've not done so yet. I can also run some dependencies either via dedicated maven plugins or code running in the application itself.

I've also written code that duplicates the way third party REST APIs work as controllers in my own project, so that a simple configuration switch means that I can use the local version instead. This only works when there is very little - if any - state to manage. Generally I've done this with third party authentication, such as Google+.

The end result of all this is that I can carry on developing even if I've got no connectivity at all. And, as a side effect, it makes development more efficient and more reliable.

Top comments (0)