inversion of control with structuremap

21
The Easy Lif Inversion of Control with Structur Brad Tutterow www.twitter.com/codebadger www.smips.com/smip/blogs/ codebadger

Upload: brad-tutterow

Post on 10-May-2015

1.101 views

Category:

Technology


1 download

DESCRIPTION

Simplify your life with Inversion of Control! One of the most challenging aspects of software development is dealing with code that depends on other code. The Dependency Inversion principle tells us that we should depend on abstractions, not concretions but it doesn’t tell us how to do that. That’s where Dependency Injection comes in – we inject our dependencies into the mushy center of our classes with a big syringe. This can often be as messy as it sounds, but luckily Inversion of Control Containers can help us by providing a single source for configuring dependencies. This presentation will show how to effectively manage dependencies with StructureMap, an open-source IOC container. StructureMap can make your life easier, your code more maintainable, and the world a better place.

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!