solid software principles with c#

19
SOLID Software Development Ken Burkhardt

Upload: ken-burkhardt

Post on 30-Jun-2015

123 views

Category:

Technology


1 download

DESCRIPTION

A small talk I did on Solid Principles

TRANSCRIPT

Page 1: SOLID Software Principles with C#

SOLID Software Development

Ken Burkhardt

Page 2: SOLID Software Principles with C#
Page 3: SOLID Software Principles with C#

What is SOLID?

Single Responsibility Principle Open Closed Principle

Liskov Substitution PrincipleInterface Segregation PrincipleDependency Inversion Principle

Page 4: SOLID Software Principles with C#

Why SOLID?

S.O.L.I.D. is a collection of best-practice, object-oriented design

principles which can be applied to your design, allowing you to

accomplish various desirable goals such as loose-coupling, higher

maintainability

Page 5: SOLID Software Principles with C#

Single Responsibility Principle

THERE SHOULD NEVER BE MORE THAN ONE REASON FOR A CLASS TO

CHANGE.

Page 6: SOLID Software Principles with C#
Page 7: SOLID Software Principles with C#

Demo - Superclass

Page 8: SOLID Software Principles with C#

Open Closed Principle

SOFTWARE ENTITIES SHOULD BE OPEN FOR EXTENSION BUT CLOSED

FOR MODIFICATION

Page 9: SOLID Software Principles with C#
Page 10: SOLID Software Principles with C#

Demo – Add New Validator

Page 11: SOLID Software Principles with C#

Liskov Substitution Principle

You should be able to use any derived class in place of a parent class and have it behave in the same manner without modification. It ensures that a derived class does not affect the behavior of

the parent class, i.e. that a derived class must be substitutable for its base class.

Page 12: SOLID Software Principles with C#
Page 13: SOLID Software Principles with C#

Interface Segregation Principle

CLIENTS SHOULD NOT BE FORCED TO DEPEND UPON INTERFACES THAT

THEY DO NOT USE

Page 14: SOLID Software Principles with C#
Page 15: SOLID Software Principles with C#

Demo - Animals

Page 16: SOLID Software Principles with C#

Dependency Inversion Principle

A. HIGH LEVEL MODULES SHOULD NOT DEPEND UPON LOW LEVEL MODULES. BOTH SHOULD DEPEND UPON ABSTRACTIONS

B. ABSTRACTIONS SHOULD NOT DEPEND UPON DETAILS. DETAILS SHOULD DEPEND UPON ABSTRACTIONS

Page 17: SOLID Software Principles with C#
Page 18: SOLID Software Principles with C#

Bad designs and poor code is not good because it's hard to change. Bad designs are:

- Rigid (change affects too many parts of the system) - Fragile (every change breaks something unexpected) - Immobile (impossible to reuse)

Page 19: SOLID Software Principles with C#

Demo - Interfaces