DUTDIP - Don't Use This Dependency Injection Pattern

By Rushabh Dadbhawala

Elevator Pitch

A thought experiment in designing a DI system for GoLang, bringing out subtle nuances of the language, especially when compared to traditional object oriented languages. Brings out possibilities and challenges of the language, and enlightens you on things you shouldn’t do!

Description

DUTDIP on Github

A project required a “slightly” more elaborate Dependency Injection system, where simple “New” functions of the package seemed inadequate. DUTDIP explores building such a system in a loop of challenge-design-build steps. Unfortunately, or not, it goes into patterns that are not the typical GoLang convention … but breaking rules is always fun, isn’t it?

DUTDIP provides a pattern that by itself doesn’t need any third party implementation to consume, and can be simply built in the project itself. It also brought out subtle GoLang nuances in a way that helped better understand the language and how to get things done in it. On the flip side, DUTDIP became a pattern that we couldn’t collectively build a consensus on…. the jury is still out on this one! However, various teams took inspiration from this pattern (positively or otherwise) to define good DI patterns for their respective projects.

Notes

Who is the intended audience for your talk? This talk is for those looking for a deeper discussion of Go language semantics and a thought experiment in design at code level using Dependency Injection as the problem to be solved.

What will attendees get out of your talk? When they leave the room, what will they know that they didn’t know before? A spectrum of options for creating your own Dependency Injection framework, and choosing a variant that best suits your needs. Things that you can do in GoLang, and things that you can but shouldn’t!