SlideShare a Scribd company logo
Slaying Sacred Cows:
Deconstructing
Dependency Injection
Tomer Gabel
Full Disclosure
• I was never a fan
• I tried researching
this properly…
– Read a ton of material
– Interviewed people
– Sat and thought
• Still turned out a rant
Image: ImgFlip
Semantics
When I say “dependency injection”, you’re
probably thinking of this:
public class BillingModule extends AbstractModule {
@Override
protected void configure() {
bind(TransactionLog.class).to(DatabaseTransactionLog.class);
bind(CreditCardProcessor.class).to(PaypalCreditCardProcessor.class);
}
}
So did I.
1. THE “D” IN SOLID
Image: Peter von Bagh, “Just Frozen Water” via Flickr (CC0 1.0 Public Domain)
Back to Basics
• Single responsibility
• Open/closed
• Liskov substitution principle
• Interface segregation
• Dependency inversion
Image: Michael Feathers via MozaicWorks
Back to Basics
• Single responsibility
• Open/closed
• Liskov substitution principle
• Interface segregation
• Dependency inversion
Image: Michael Feathers via MozaicWorks
Dependency Inversion
• A simple idea
• Given a dependency:
– A must not depend on B
directly
OAuthProvider
MysqlUserStore
“A”
“B”
Dependency Inversion
• A simple idea
• Given a dependency:
– A must not depend on B
directly
– Instead, A depends on
an abstraction of B
– B depends on the
same abstraction
OAuthProvider
MysqlUserStore
UserStore
class
class
interface
“A”
“B”
The Verdict
• Dependency
inversion is old hat
– Seems obvious now
– First postulated by
Uncle Bob in 1994 (!)
• We’ve come a long
way since!
“The philosophy of
one century is the
common sense
of the next.”
-- Henry Ward
Beecher
Image: Mathew Brady, “Henry Ward Beecher” via Library of Congress (Public Domain)
2. DECOUPLE
ME SOFTLY
Image: Mark Menzies, “Le Chav Sportif” via Flickr (CC-BY-NC-SA 2.0)
Dependency Injection
• Let’s assume SOLID…
• Given a dependency:
– Who owns it?
– What is the lifecycle?
• Traditionally:
– The depending service
manages everything
class UserService {
private UserStore store =
new MysqlUserStore(Config.JDBC_URL);
bool authenticate(String userToken) {
UserContext user =
store.lookup(userToken);
return user != null
? user.isActive()
: false;
}
}
Dependency Injection
• DI stipulates:
– Services should not
build dependencies
– But instead receive them
– Dependencies are state
• It does not stipulate
how to implement this
class UserService {
private UserStore store;
public UserService(UserStore store) {
this.store = store;
}
bool authenticate(String userToken) {
// ...
}
}
The Verdict
• Dependency
injection is good
• If taken at face value:
– No frameworks
– No containers
– No reflection
– Simply common sense
Image: Tomas Catelazo via Wikimedia Commons (CC-BY-SA 4.0)
3. THINGS
GET HAIRY
Image: Matt Acevedo, “Alpaca” via Flickr (CC-BY 2.0)
Inversion of Control
• IoC is not a pattern
• It’s a design principle
• Traditionally:
– “Main” flow calls into
components
– Control flows back to
the “main” flow
Main (entry point)
• Configuration
• Bootstrapping
Event loop
• Dequeue
• Dispatch
Event handler
• Act on event
• Done
Inversion of Control
• IoC is not a pattern
• It’s a design principle
• With IoC:
– Control is surrendered
to a container
– Container calls into
components
Main (entry point)
• Setup
IoC container
• Bootstrapping/wiring
• Event loop
Event handler
• Act on event
• Done
Inversion of Control
• IoC means many things
– Servlet containers
– Plugin systems
– Stream computing
– “DI” containers
• We’ll focus on the latter
IoC & DI
• Consider Spring/Guice
– A runtime container
– Manages components
– … including lifecycle
– … and automatic wiring
Image: ImgFlip
Perceived Benefits
• Why use a container?
– Simplify wiring
– Simplify testing
– Dynamic configuration
– Support for AOP
• Let’s consider each
Image: ImgFlip
Perceived Benefits
• Why use a container?
– Simplify wiring
– Simplify testing
– Dynamic configuration
– Support for AOP
• Let’s consider each
Image: ImgFlip
Simplified Wiring
class MyApp {
DBI db = new DBIFactory().build(...);
EventStore eventStore =
new MysqlEventStore(db);
SnapshotStore snapshotStore =
new MysqlSnapshotStore(db);
Clock clock =
Clock.systemUTC();
SiteService siteService =
new DefaultSiteService(
eventStore, snapshotStore, clock);
}
Simplified Wiring
class MyApp {
DBI db = new DBIFactory().build(...);
EventStore eventStore =
new MysqlEventStore(db);
SnapshotStore snapshotStore =
new MysqlSnapshotStore(db);
Clock clock =
Clock.systemUTC();
SiteService siteService =
new DefaultSiteService(
eventStore, snapshotStore, clock);
}
class MyAppModule extends AbstractModule {
@Override
protected void configure() {
bind(DBI.class).toProvider(...);
bind(EventStore.class)
.to(MysqlEventStore.class);
bind(SnapshotStore.class)
.to(MysqlSnapshotStore.class);
bind(Clock.class)
.toProvider(Clock::systemUTC);
bind(SiteService.class)
.to(DefaultSiteService.class);
}
}
Simplified Wiring
class MyApp {
DBI db = new DBIFactory().build(...);
EventStore eventStore =
new MysqlEventStore(db);
SnapshotStore snapshotStore =
new MysqlSnapshotStore(db);
Clock clock =
Clock.systemUTC();
SiteService siteService =
new DefaultSiteService(
eventStore, snapshotStore, clock);
}
class MyAppModule extends AbstractModule {
@Override
protected void configure() {
bind(DBI.class).toProvider(...);
bind(EventStore.class)
.to(MysqlEventStore.class);
bind(SnapshotStore.class)
.to(MysqlSnapshotStore.class);
bind(Clock.class)
.toProvider(Clock::systemUTC);
bind(SiteService.class)
.to(DefaultSiteService.class);
}
}
Simplified Wiring
• No tangible benefit!
– Wiring is trivial
• Real, tangible downsides
– Startup time
– Code navigability
– Dynamic/reflective magic
Image: André Nordstrand, “Loss of common sense” via Flickr (CC-BY-NC 2.0)
Simplify Testing
• Proponents will tell you:
1. Bring up a container
2. Swap out components
3. Bob’s your uncle
Simplify Testing
deconstruction (source: dictionary.com)
Noun
1. a technique of literary analysis that regards
meaning as resulting from the differences
between words rather than their reference to
the things they stand for.
Simplify Testing
• Congratulations!
• You’re doing
deconstructive
testing
Wha-huh?
Constructive testing Deconstructive testing
MysqlEventStore
DataSource
SiteService
MysqlEventStore
DataSource
MysqlSnapshotStore
DataSource
Clock
Wha-huh?
Constructive testing Deconstructive testing
MysqlEventStore
DataSource
SiteService
MysqlEventStore
DataSource
MockSnapshotStore
Fixed
Clock
Simplify Testing
• This is a bad idea
– Hard to reason about
– Have to deal with
subtle interactions
– Does not reflect your
unit structure
• Most importantly…
– Leads to poor design!
Image: Viewminder, “Strange Bedfellows” via Flickr (CC-BY-NC-ND 2.0)
IN SUMMARY…
IoC is a solution in
search of a problem
… except …
• With huge codebases
– Read: “Monoliths”
– Read: “Enterprise”
• Enables a tradeoff
– Developer discipline
– Code coherence,
simplicity, navigability
… except …
• With huge codebases
– Read: “Monoliths”
– Read: “Enterprise”
• Enables a tradeoff
– Developer discipline
– Code coherence,
simplicity, navigability
Corollary:
If you’re seeing
benefit from IoC,
your codebase is
already out of
control.
QUESTIONS?
Thank you for listening
tomer@tomergabel.com
@tomerg
http://engineering.wix.com
Sample Project:
http://tinyurl.com/event-sourcing-sample
This work is licensed under a Creative
Commons Attribution-ShareAlike 4.0
International License.

More Related Content

PDF
An Abridged Guide to Event Sourcing
PDF
CloudStack, jclouds, Jenkins and CloudCat
PPTX
Eddystone Beacons - Physical Web - Giving a URL to All Objects
PDF
A year in the life of a Grails startup
PPTX
Why Play Framework is fast
PDF
TIAD : Automating the modern datacenter
PDF
Deployment of WebObjects applications on FreeBSD
PDF
TIAD - DYI: A simple orchestrator built step by step
An Abridged Guide to Event Sourcing
CloudStack, jclouds, Jenkins and CloudCat
Eddystone Beacons - Physical Web - Giving a URL to All Objects
A year in the life of a Grails startup
Why Play Framework is fast
TIAD : Automating the modern datacenter
Deployment of WebObjects applications on FreeBSD
TIAD - DYI: A simple orchestrator built step by step

What's hot (20)

PPTX
OpenStack 101 - All Things Open 2015
PPTX
Planning to Fail #phpne13
PPTX
OpenStack: Toward a More Resilient Cloud
PDF
NYC Cassandra Day - Java Intro
PPTX
DefCore: The Interoperability Standard for OpenStack
PPTX
Luc Dekens - Italian vmug usercon
PPTX
Interoperability: The Elephants in the Room & What We're Doing About Them
PDF
OpenNebulaConf2015 1.07 Cloud for Scientific Computing @ STFC - Alexander Dibbo
PDF
Opscode-Eucalyptus Webinar 20110721
PDF
Micronaut For Single Page Apps
PPTX
OpenStack + VMware: Deploy, Upgrade, & Operate a Powerful Production OpenStac...
PDF
LJC: Microservices in the real world
PPTX
Openstack 101
PPTX
server to cloud: converting a legacy platform to an open source paas
PPTX
Planning to Fail #phpuk13
PDF
vBrownBag - Scripting and Versioning with PowerShell ISE and Git Shell
KEY
Novalug 07142012
PDF
Basic Understanding and Implement of Node.js
PDF
(SCALE 12x) OpenStack vs. VMware - A System Administrator Perspective
PPTX
Skipping OpenStack Releases: (You Don't) Gotta Catch 'Em All
OpenStack 101 - All Things Open 2015
Planning to Fail #phpne13
OpenStack: Toward a More Resilient Cloud
NYC Cassandra Day - Java Intro
DefCore: The Interoperability Standard for OpenStack
Luc Dekens - Italian vmug usercon
Interoperability: The Elephants in the Room & What We're Doing About Them
OpenNebulaConf2015 1.07 Cloud for Scientific Computing @ STFC - Alexander Dibbo
Opscode-Eucalyptus Webinar 20110721
Micronaut For Single Page Apps
OpenStack + VMware: Deploy, Upgrade, & Operate a Powerful Production OpenStac...
LJC: Microservices in the real world
Openstack 101
server to cloud: converting a legacy platform to an open source paas
Planning to Fail #phpuk13
vBrownBag - Scripting and Versioning with PowerShell ISE and Git Shell
Novalug 07142012
Basic Understanding and Implement of Node.js
(SCALE 12x) OpenStack vs. VMware - A System Administrator Perspective
Skipping OpenStack Releases: (You Don't) Gotta Catch 'Em All
Ad

Similar to Slaying Sacred Cows: Deconstructing Dependency Injection (20)

PPT
Spring IOC
PPTX
The Spring Framework: A brief introduction to Inversion of Control
PPTX
Dependency injection using Google guice
PPTX
Cut your Dependencies with Dependency Injection - .NET User Group Osnabrueck
PDF
Dependency injection in Java, from naive to functional
PPTX
Dependency Inversion Principle
PPTX
Dependency Injection
PPT
Spring io c
PPTX
Clean Code Part II - Dependency Injection at SoCal Code Camp
PDF
Mock Objects, Design and Dependency Inversion Principle
PPTX
Cut your Dependencies with Dependency Injection for East Bay.NET User Group
PDF
Dependency Injection
PPTX
Dip(dependency inversion principle) presentation
PPTX
Dependency injection with Symfony 2
PPTX
Cut your Dependencies - Dependency Injection at Silicon Valley Code Camp
PPTX
Inversion of Control and Dependency Injection
PPTX
The Dependency Injection - Sorin Damian, Software Developer@RomSoft
PPTX
Clean Code II - Dependency Injection at SoCal Code Camp San Diego (07/27/2013)
PPTX
I gotta dependency on dependency injection
PPTX
Clean Code II - Dependency Injection
Spring IOC
The Spring Framework: A brief introduction to Inversion of Control
Dependency injection using Google guice
Cut your Dependencies with Dependency Injection - .NET User Group Osnabrueck
Dependency injection in Java, from naive to functional
Dependency Inversion Principle
Dependency Injection
Spring io c
Clean Code Part II - Dependency Injection at SoCal Code Camp
Mock Objects, Design and Dependency Inversion Principle
Cut your Dependencies with Dependency Injection for East Bay.NET User Group
Dependency Injection
Dip(dependency inversion principle) presentation
Dependency injection with Symfony 2
Cut your Dependencies - Dependency Injection at Silicon Valley Code Camp
Inversion of Control and Dependency Injection
The Dependency Injection - Sorin Damian, Software Developer@RomSoft
Clean Code II - Dependency Injection at SoCal Code Camp San Diego (07/27/2013)
I gotta dependency on dependency injection
Clean Code II - Dependency Injection
Ad

More from Tomer Gabel (20)

PDF
How shit works: Time
PDF
Nondeterministic Software for the Rest of Us
PDF
How shit works: the CPU
PDF
How Shit Works: Storage
PDF
Java 8 and Beyond, a Scala Story
PDF
The Wix Microservice Stack
PPTX
Scala Refactoring for Fun and Profit (Japanese subtitles)
PPTX
Scala Refactoring for Fun and Profit
PDF
Onboarding at Scale
PPTX
Scala in the Wild
PPTX
Speaking Scala: Refactoring for Fun and Profit (Workshop)
PPTX
Put Your Thinking CAP On
PPTX
Leveraging Scala Macros for Better Validation
PDF
A Field Guide to DSL Design in Scala
PPTX
Functional Leap of Faith (Keynote at JDay Lviv 2014)
PPTX
Scala Back to Basics: Type Classes
PDF
5 Bullets to Scala Adoption
PPTX
Nashorn: JavaScript that doesn’t suck (ILJUG)
PDF
Ponies and Unicorns With Scala
PPTX
Lab: JVM Production Debugging 101
How shit works: Time
Nondeterministic Software for the Rest of Us
How shit works: the CPU
How Shit Works: Storage
Java 8 and Beyond, a Scala Story
The Wix Microservice Stack
Scala Refactoring for Fun and Profit (Japanese subtitles)
Scala Refactoring for Fun and Profit
Onboarding at Scale
Scala in the Wild
Speaking Scala: Refactoring for Fun and Profit (Workshop)
Put Your Thinking CAP On
Leveraging Scala Macros for Better Validation
A Field Guide to DSL Design in Scala
Functional Leap of Faith (Keynote at JDay Lviv 2014)
Scala Back to Basics: Type Classes
5 Bullets to Scala Adoption
Nashorn: JavaScript that doesn’t suck (ILJUG)
Ponies and Unicorns With Scala
Lab: JVM Production Debugging 101

Recently uploaded (20)

PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
Lecture Notes Electrical Wiring System Components
PPT
Project quality management in manufacturing
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PPTX
Internet of Things (IOT) - A guide to understanding
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
DOCX
573137875-Attendance-Management-System-original
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
Lecture Notes Electrical Wiring System Components
Project quality management in manufacturing
Foundation to blockchain - A guide to Blockchain Tech
R24 SURVEYING LAB MANUAL for civil enggi
Internet of Things (IOT) - A guide to understanding
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
UNIT-1 - COAL BASED THERMAL POWER PLANTS
CH1 Production IntroductoryConcepts.pptx
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Automation-in-Manufacturing-Chapter-Introduction.pdf
573137875-Attendance-Management-System-original
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...

Slaying Sacred Cows: Deconstructing Dependency Injection

  • 2. Full Disclosure • I was never a fan • I tried researching this properly… – Read a ton of material – Interviewed people – Sat and thought • Still turned out a rant Image: ImgFlip
  • 3. Semantics When I say “dependency injection”, you’re probably thinking of this: public class BillingModule extends AbstractModule { @Override protected void configure() { bind(TransactionLog.class).to(DatabaseTransactionLog.class); bind(CreditCardProcessor.class).to(PaypalCreditCardProcessor.class); } } So did I.
  • 4. 1. THE “D” IN SOLID Image: Peter von Bagh, “Just Frozen Water” via Flickr (CC0 1.0 Public Domain)
  • 5. Back to Basics • Single responsibility • Open/closed • Liskov substitution principle • Interface segregation • Dependency inversion Image: Michael Feathers via MozaicWorks
  • 6. Back to Basics • Single responsibility • Open/closed • Liskov substitution principle • Interface segregation • Dependency inversion Image: Michael Feathers via MozaicWorks
  • 7. Dependency Inversion • A simple idea • Given a dependency: – A must not depend on B directly OAuthProvider MysqlUserStore “A” “B”
  • 8. Dependency Inversion • A simple idea • Given a dependency: – A must not depend on B directly – Instead, A depends on an abstraction of B – B depends on the same abstraction OAuthProvider MysqlUserStore UserStore class class interface “A” “B”
  • 9. The Verdict • Dependency inversion is old hat – Seems obvious now – First postulated by Uncle Bob in 1994 (!) • We’ve come a long way since! “The philosophy of one century is the common sense of the next.” -- Henry Ward Beecher Image: Mathew Brady, “Henry Ward Beecher” via Library of Congress (Public Domain)
  • 10. 2. DECOUPLE ME SOFTLY Image: Mark Menzies, “Le Chav Sportif” via Flickr (CC-BY-NC-SA 2.0)
  • 11. Dependency Injection • Let’s assume SOLID… • Given a dependency: – Who owns it? – What is the lifecycle? • Traditionally: – The depending service manages everything class UserService { private UserStore store = new MysqlUserStore(Config.JDBC_URL); bool authenticate(String userToken) { UserContext user = store.lookup(userToken); return user != null ? user.isActive() : false; } }
  • 12. Dependency Injection • DI stipulates: – Services should not build dependencies – But instead receive them – Dependencies are state • It does not stipulate how to implement this class UserService { private UserStore store; public UserService(UserStore store) { this.store = store; } bool authenticate(String userToken) { // ... } }
  • 13. The Verdict • Dependency injection is good • If taken at face value: – No frameworks – No containers – No reflection – Simply common sense Image: Tomas Catelazo via Wikimedia Commons (CC-BY-SA 4.0)
  • 14. 3. THINGS GET HAIRY Image: Matt Acevedo, “Alpaca” via Flickr (CC-BY 2.0)
  • 15. Inversion of Control • IoC is not a pattern • It’s a design principle • Traditionally: – “Main” flow calls into components – Control flows back to the “main” flow Main (entry point) • Configuration • Bootstrapping Event loop • Dequeue • Dispatch Event handler • Act on event • Done
  • 16. Inversion of Control • IoC is not a pattern • It’s a design principle • With IoC: – Control is surrendered to a container – Container calls into components Main (entry point) • Setup IoC container • Bootstrapping/wiring • Event loop Event handler • Act on event • Done
  • 17. Inversion of Control • IoC means many things – Servlet containers – Plugin systems – Stream computing – “DI” containers • We’ll focus on the latter
  • 18. IoC & DI • Consider Spring/Guice – A runtime container – Manages components – … including lifecycle – … and automatic wiring Image: ImgFlip
  • 19. Perceived Benefits • Why use a container? – Simplify wiring – Simplify testing – Dynamic configuration – Support for AOP • Let’s consider each Image: ImgFlip
  • 20. Perceived Benefits • Why use a container? – Simplify wiring – Simplify testing – Dynamic configuration – Support for AOP • Let’s consider each Image: ImgFlip
  • 21. Simplified Wiring class MyApp { DBI db = new DBIFactory().build(...); EventStore eventStore = new MysqlEventStore(db); SnapshotStore snapshotStore = new MysqlSnapshotStore(db); Clock clock = Clock.systemUTC(); SiteService siteService = new DefaultSiteService( eventStore, snapshotStore, clock); }
  • 22. Simplified Wiring class MyApp { DBI db = new DBIFactory().build(...); EventStore eventStore = new MysqlEventStore(db); SnapshotStore snapshotStore = new MysqlSnapshotStore(db); Clock clock = Clock.systemUTC(); SiteService siteService = new DefaultSiteService( eventStore, snapshotStore, clock); } class MyAppModule extends AbstractModule { @Override protected void configure() { bind(DBI.class).toProvider(...); bind(EventStore.class) .to(MysqlEventStore.class); bind(SnapshotStore.class) .to(MysqlSnapshotStore.class); bind(Clock.class) .toProvider(Clock::systemUTC); bind(SiteService.class) .to(DefaultSiteService.class); } }
  • 23. Simplified Wiring class MyApp { DBI db = new DBIFactory().build(...); EventStore eventStore = new MysqlEventStore(db); SnapshotStore snapshotStore = new MysqlSnapshotStore(db); Clock clock = Clock.systemUTC(); SiteService siteService = new DefaultSiteService( eventStore, snapshotStore, clock); } class MyAppModule extends AbstractModule { @Override protected void configure() { bind(DBI.class).toProvider(...); bind(EventStore.class) .to(MysqlEventStore.class); bind(SnapshotStore.class) .to(MysqlSnapshotStore.class); bind(Clock.class) .toProvider(Clock::systemUTC); bind(SiteService.class) .to(DefaultSiteService.class); } }
  • 24. Simplified Wiring • No tangible benefit! – Wiring is trivial • Real, tangible downsides – Startup time – Code navigability – Dynamic/reflective magic Image: André Nordstrand, “Loss of common sense” via Flickr (CC-BY-NC 2.0)
  • 25. Simplify Testing • Proponents will tell you: 1. Bring up a container 2. Swap out components 3. Bob’s your uncle
  • 26. Simplify Testing deconstruction (source: dictionary.com) Noun 1. a technique of literary analysis that regards meaning as resulting from the differences between words rather than their reference to the things they stand for.
  • 27. Simplify Testing • Congratulations! • You’re doing deconstructive testing
  • 28. Wha-huh? Constructive testing Deconstructive testing MysqlEventStore DataSource SiteService MysqlEventStore DataSource MysqlSnapshotStore DataSource Clock
  • 29. Wha-huh? Constructive testing Deconstructive testing MysqlEventStore DataSource SiteService MysqlEventStore DataSource MockSnapshotStore Fixed Clock
  • 30. Simplify Testing • This is a bad idea – Hard to reason about – Have to deal with subtle interactions – Does not reflect your unit structure • Most importantly… – Leads to poor design! Image: Viewminder, “Strange Bedfellows” via Flickr (CC-BY-NC-ND 2.0)
  • 31. IN SUMMARY… IoC is a solution in search of a problem
  • 32. … except … • With huge codebases – Read: “Monoliths” – Read: “Enterprise” • Enables a tradeoff – Developer discipline – Code coherence, simplicity, navigability
  • 33. … except … • With huge codebases – Read: “Monoliths” – Read: “Enterprise” • Enables a tradeoff – Developer discipline – Code coherence, simplicity, navigability Corollary: If you’re seeing benefit from IoC, your codebase is already out of control.
  • 34. QUESTIONS? Thank you for listening tomer@tomergabel.com @tomerg http://engineering.wix.com Sample Project: http://tinyurl.com/event-sourcing-sample This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.