Agile Design Principles, a Precursor to .Net Design Patterns

19
Oxygen Blast Series Slide 1 @IntertechInc #oxygenblast SOLID Agile Software Design Principles- C# A Consulting Division Presentation Month Date, 2006 — © — All Rights Reserved Tim Star [email protected] http://www.intertech.com/Blog/

description

Before diving into full-blown design patterns it is good to review what have become known as the Agile Design Principles. Maintaining an understanding of design principles is key as we use design patterns in our projects because the two are so closely tied together. In this hour session Tim Star will discuss the Single responsibility principle (SRP), Open Closed Principle (OCP), Liskov Substitution Principle (LSP), Interface Segregation Principle (ISP) and the Dependency Inversion Principle (DIP).

Transcript of Agile Design Principles, a Precursor to .Net Design Patterns

Page 1: Agile Design Principles, a Precursor to .Net Design Patterns

Oxygen Blast Series

Slide 1@IntertechInc #oxygenblast

SOLID Agile Software Design Principles- C#

A Consulting Division Presentation

Month Date, 2006 — © — All Rights Reserved

Tim Star

[email protected]://www.intertech.com/Blog/

Page 2: Agile Design Principles, a Precursor to .Net Design Patterns

Oxygen Blast Series

Slide 2@IntertechInc #oxygenblast

Intertech

Training Training through hands-on, real

world business examples. Our site, your site, or live

online – globally. Agile/Scrum, Citrix, VMware,

Oracle, IBM, Microsoft, Java/Open Source, and web and mobile technologies.

Consulting Design and develop software

that powers businesses and governments of all sizes.

On-site consulting, outsourcing, and mentoring.

Agile, .NET, Java, SQL Server, mobile development including iPhone and Android platforms and more….

Instructors Who Consult, Consultants Who Teach

Our Company Over 35 awards for growth,

innovation and workplace best practices.

99.7% satisfaction score from our consulting and training customers.

Yearly “Best Places to Work” winner in Minnesota.

Page 3: Agile Design Principles, a Precursor to .Net Design Patterns

Oxygen Blast Series

Slide 3@IntertechInc #oxygenblast

Principal Consultant / .Net Architect Writing Software over 20 Years 5 X Microsoft MVP Visual Studio ALM Ranger – 6 years MCPD Enterprise App Development 3.5/4.0 Framework MCTS WPF/TFS MCP – VS ALM and Testing with MTM MCT

Experience – Tim Star

Page 4: Agile Design Principles, a Precursor to .Net Design Patterns

Oxygen Blast Series

Slide 4@IntertechInc #oxygenblast

Single Responsibility Principle (SRP)Open Closed Principle (OCP)Liskov Substitution Principle (LSP)Interface Segregation Principle (ISP)Dependency Inversion Principle (DIP)

Simple Examples

Agenda

Page 5: Agile Design Principles, a Precursor to .Net Design Patterns

Oxygen Blast Series

Slide 5@IntertechInc #oxygenblast

We want the “ability to develop software quickly, in the face of rapidly changing requirements”. – “Uncle Bob” Martin

Flexibility Maintainability Testability

Motivation

Page 6: Agile Design Principles, a Precursor to .Net Design Patterns

Oxygen Blast Series

Slide 6@IntertechInc #oxygenblast

Every class should have a single responsibility, and that responsibility should be entirely encapsulated by the class. All its services should be narrowly aligned with that responsibility

Martin defines a responsibility as a reason to change, and concludes that a class or module should have one, and only one, reason to change.

Single Responsibility Principle

Page 7: Agile Design Principles, a Precursor to .Net Design Patterns

Oxygen Blast Series

Slide 7@IntertechInc #oxygenblast

Benefits Highly cohesive classes are easier to maintain Simplifies testing

Drawbacks More classes tends to add complexity

Code Smells Class with 1000’s of Lines of Code Class with Many unrelated or loosely related Methods

SRP Continued

Page 8: Agile Design Principles, a Precursor to .Net Design Patterns

Oxygen Blast Series

Slide 8@IntertechInc #oxygenblast

Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification

Open Closed Principle

Page 9: Agile Design Principles, a Precursor to .Net Design Patterns

Oxygen Blast Series

Slide 9@IntertechInc #oxygenblast

Benefits Working code stays working Changes are achieved via new code

Drawbacks Tends to add complexity

Code Smells Switch logic If/Then/Else TypeOf()

OCP Continued

Page 10: Agile Design Principles, a Precursor to .Net Design Patterns

Oxygen Blast Series

Slide 10@IntertechInc #oxygenblast

Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program

Liskov Substitution Principle

Page 11: Agile Design Principles, a Precursor to .Net Design Patterns

Oxygen Blast Series

Slide 11@IntertechInc #oxygenblast

Benefits Reuse Maintainable Robust

Drawbacks Code Smells

Method Hiding Not Implemented Exception Covariance object[] array = new String[10]; Derived Class Violates Reasonable Assumptions

LSP Continued

Page 12: Agile Design Principles, a Precursor to .Net Design Patterns

Oxygen Blast Series

Slide 12@IntertechInc #oxygenblast

Many client-specific interfaces are better than one general-purpose interface

Interface Segregation Principle

Page 13: Agile Design Principles, a Precursor to .Net Design Patterns

Oxygen Blast Series

Slide 13@IntertechInc #oxygenblast

Benefits Less Code Lower Test Impact with Change

Drawbacks Adds Complexity – Can “Overdo It”

Code Smells Long Interfaces Interfaces with Unrelated Concerns

ISP Continued

Page 14: Agile Design Principles, a Precursor to .Net Design Patterns

Oxygen Blast Series

Slide 14@IntertechInc #oxygenblast

Depend upon Abstractions. Do not depend upon concretions.

Dependency Inversion Principle

Page 15: Agile Design Principles, a Precursor to .Net Design Patterns

Oxygen Blast Series

Slide 15@IntertechInc #oxygenblast

Benefits Maintainable / Resilient To Change Testable

Drawbacks Adds Complexity – Can “Overdo It”

Code Smells New()

DIP Continued

Page 16: Agile Design Principles, a Precursor to .Net Design Patterns

Oxygen Blast Series

Slide 16@IntertechInc #oxygenblast

Demo

SOLID

Page 18: Agile Design Principles, a Precursor to .Net Design Patterns

Oxygen Blast Series

Slide 18@IntertechInc #oxygenblast

Next Oxygen Blasts July 30th

iOS 7: Utilizing Push Notifications in Your App with Xcode 5 August 13th

Creating Your Own Dynamic LINQ Statements with Expression Trees

Upcoming Training .NET Design Patterns

June 16-18th

To learn more: http://bit.ly/1wBnImm

Upcoming Webinars and Training

Page 19: Agile Design Principles, a Precursor to .Net Design Patterns

Oxygen Blast Series

Slide 19@IntertechInc #oxygenblast

Questions or Feedback?Patrick Schaber – [email protected]

Thank You