8

Click here to load reader

Code Like a Ninja Session 6 - Dependency Inversion Principle

Embed Size (px)

Citation preview

Page 1: Code Like a Ninja Session 6 - Dependency Inversion Principle

CODE LIKE A NINJATHE DEPENDENCY INVERSION PRINCIPLE

Page 2: Code Like a Ninja Session 6 - Dependency Inversion Principle

SESSION RESOURCES

• Presentation session notes including link to this session, will be available on http://learningaboutfudge.blogspot.com

• All the source for this session is publically available at: https://github.com/SheepWorx/Training

• RSS Feed: http://learningaboutfudge.blogspot.com/feeds/posts/default?alt=rss

• Local Network: \\dmeyer-m\share\training\Code Like a Ninja

• Source was compiled using Visual Studio 2012

Page 3: Code Like a Ninja Session 6 - Dependency Inversion Principle

Single Responsibility PrincipleOpen/Close PrincipleLiskov’s Substitution PrincipleInterface Segregation PrincipleDependency Inversion Principle

Page 4: Code Like a Ninja Session 6 - Dependency Inversion Principle
Page 5: Code Like a Ninja Session 6 - Dependency Inversion Principle

DEFINITION

The Dependency Inversion Principle

High level modules should not depend upon low level modules. Both should depend upon abstractions

Abstractions should not depend upon details. Details should depend upon abstractions

Page 6: Code Like a Ninja Session 6 - Dependency Inversion Principle

WHY?

• DIP is used to alleviate badly designed code that is code that is

• Rigid, fragile and immobile

• DIP’s primary focus is to decouple tightly coupled classes

Page 7: Code Like a Ninja Session 6 - Dependency Inversion Principle

CODE

• We already covered this in the OCP code samples- revisit them again for this session

Page 8: Code Like a Ninja Session 6 - Dependency Inversion Principle

SESSION RESOURCES

• Presentation session notes including link to this session, will be available on http://learningaboutfudge.blogspot.com

• All the source for this session is publically available at: https://github.com/SheepWorx/Training

• RSS Feed: http://learningaboutfudge.blogspot.com/feeds/posts/default?alt=rss

• Local Network: \\dmeyer-m\share\training\Code Like a Ninja

• Source was compiled using Visual Studio 2012