Dependency Injection Made Easy with Clojure

Dependency inversion is an architectural cornerstone of well implemented Clojure applications. However, many Clojure applications start out with an ad-hoc, poorly abstracted initialization model - since application initialization needs to include dependency inversion in most cases, the latter is often omitted or not given the due attention it deserves.

Not treating dependency inversion as a first class concern has devastating consequences on testability (hence robustness), comprehension and maintainability of code, and causes a vicious circle of broken-windows effect.

In this talk I will go into the details of why and how such things happen, and how one can avoid those. I will discuss dependency injection as a flavour of dependency inversion and as a practical solution to achieve cleaner application design. I will illustrate the use of dependency injection mechanism through code examples and will share my experience of using the mechanism in real world projects.

 
5 favorite thumb_down thumb_up 0 comments visibility_off  Remove from Watchlist visibility  Add to Watchlist
 

Outline/structure of the Session

The talk would be roughly structured as follows:

  • Initialization as a first class concern
    • Journey of a programmer: Hacker->Developer->Engineer
    • Opportunity for composition/wiring
    • Opportunity for instrumentation
    • Opportunity for optimization
  • Dependency injection as
    • A means of composition
    • One of the SOLID principles
  • Layered design using Higher order Functions
    • Organizing code by separating concerns
    • Explicit dependencies as a first class concern
    • Relevance with side effects (IO config params)
    • Great for testing, for simulating scenarios
  • Friction with Dependency injection mechanisms
    • Dynamic binding
    • World-passing anti pattern
    • Protocol impedance mismatch
    • Var dissociation
    • Boilerplate and sync-on-refactor
    • Incidental bootstrapping
    • Global mutable dependencies: `alter-var-root`
  • DIME, the namesake library
    • Annotated vars
    • Annotated dependencies
    • Qualified names encouraged
    • Post-inject for effect
    • Dependency graph extraction (tooling/visualization)
    • How it works
    • Extensible

 

Learning Outcome

Attendees would learn about the following:

  • Importance of Dependency-inversion in application design
  • Why does dependency inversion often not receive proper attention
  • Cleaner functional programming approach using dependency injection
  • Dependency injection anti-patterns to avoid in Clojure
  • An easy way to carry out clean dependency injection in Clojure

 

Target Audience

Intermediate Clojure programmers, or programmers experienced in other languages looking for Clojure best practices

schedule Submitted 1 year ago

Comments Subscribe to Comments

comment Comment on this Proposal

  • Liked Shantanu Kumar
    keyboard_arrow_down

    Shantanu Kumar - Performance optimization with Code-as-data in Clojure

    Shantanu Kumar
    Shantanu Kumar
    Principal Engineer
    Concur
    schedule 1 year ago
    Sold Out!
    45 Mins
    Talk
    Advanced

    Homoiconicity (code as data, data as code) is one of the hallmarks of Lisp. Clojure, a Lisp-1 language, has this wonderful feature too. In this talk I will discuss about performance optimization techniques that leverage homoiconicity.

    No discussion on performance optimization can happen without discussing performance benchmarking. In this talk I will show how to do comparative benchmarking while trying to find performance bottlenecks. I will then proceed to showing techniques on using Clojure's homoiconicity to optimize performance. I will also show how to discover latency breakup of any Clojure code in a waterfall-chart model using homoiconicity.

  • Liked Rahul Muttineni
    keyboard_arrow_down

    Rahul Muttineni - Bringing the Power of Haskell to the JVM

    Rahul Muttineni
    Rahul Muttineni
    Co-Founder
    TypeLead
    schedule 1 year ago
    Sold Out!
    45 Mins
    Experience Report
    Advanced

    The JVM is a state-of-the-art, cross-platform virtual machine supported by the vast Java platform and ecosystem, but is cursed with an ancient and clumsy language that is slowly modernizing. Haskell is a state-of-the-art programming language with immature platform and tooling and no commercial development of its primary implementation. GHCVM's objective is to combine the best of both worlds and reap the benefits.

    In this talk, I will share my journey of how I waded through the internals of GHC and got Haskell and Java to play nice with each other.