When a new team spins up at Pivotal time is set aside to get everyone onboard with the basic principles of XP, SOLID and TDD.

Today we walked through dependency inversion. Here are my notes.

Agenda

  1. Definitions
  2. History
  3. Modeling Exercises
  4. Refactoring
  5. TDD Exercise

Definitions

Dependency Injection. Dependency Inversion. How are they related?

Dependency Inversion

  • Compile time dependencies vs runtime flow of control.
  • High level policy should be independent of low level detail.
  • Concretions should depend on abstractions.
  • Depend in the direction of stability.

Injection allows you to provide dependencies to something else.

history

First working example. 1978. Using the Z 80 Assembler language. In a phone system. One release of their software. A new company. In memory reallocation.

Awesome Payoffs

  • More readable code.
  • More freedom at the time of build.
  • Testability.
  • Open to expansion. Closed to modification.
  • programming by wishful thinking.

Types of test doubles

  1. Mocks
  2. Dummy
  3. Spy
  4. Fake
  5. Stub

Reservations

  • Does it make sense to shift the contract with only once device?
  • Naming contracts based on behaviour is scary.