Transcript
Page 1: Inversion of Control with StructureMap

The Easy LifeInversion of Control with StructureMap

Brad Tutterow

www.twitter.com/codebadger

www.smips.com/smip/blogs/codebadger

Page 2: Inversion of Control with StructureMap

What is a dependency?

Page 3: Inversion of Control with StructureMap

Any thing the code I’m working on needs to work that is not the code I’m working

on

Database File System Web Content

Services Email Other Code

Page 4: Inversion of Control with StructureMap

Our Problem SpaceTIME TO USE YOUR IMAGINATION

Page 6: Inversion of Control with StructureMap

Get the current market price for a sprocket

Check for a quantity discount

Return the final price

Page 7: Inversion of Control with StructureMap

Get the current market price for a sprocket

Call the Sprocket Market web service

Check for a quantity discount

Look it up in the sales database

Return the final price

Multiply the discount price by the quantity requested

Page 8: Inversion of Control with StructureMap
Page 9: Inversion of Control with StructureMap

“High-level modules should not depend on low-level modules. Both should depend on

abstractions.”

Dependency Inversion Principle

Page 10: Inversion of Control with StructureMap

“High-level modules should not depend on low-level modules. Both should depend on

abstractions.”

Page 11: Inversion of Control with StructureMap

Are dependencies bad?

Page 16: Inversion of Control with StructureMap

“High-level modules should not depend on low-level modules. Both should depend on

abstractions.”

Dependency Inversion Principle

Page 17: Inversion of Control with StructureMap

SprocketStore

SalesDatabase

SprocketStore

SalesDatabase

ISalesDatabase

Page 20: Inversion of Control with StructureMap

Here we go!


Top Related