solid and better design

28
SOLID and Better Design hoto by Roy Higson. http://www.fotopedia.com/items/roytheboy-Q13G6ugLM0I SOLID and Better Design Toni Tassani March 2013

Upload: toni-tassani

Post on 06-May-2015

363 views

Category:

Technology


1 download

DESCRIPTION

SOLID Principles for Better Software Design

TRANSCRIPT

Page 1: SOLID and Better Design

SOLIDand Better Design

Photo by Roy Higson. http://www.fotopedia.com/items/roytheboy-Q13G6ugLM0I

SOLIDand Better Design

Toni TassaniMarch 2013

Page 2: SOLID and Better Design

Writing Software is not hard

You spend more time Reading and Modifying it

Page 3: SOLID and Better Design

Design Smells

1. Rigidity2. Fragility3. Immobility4. Viscosity5. Needless Complexity6. Needless repetition7. Opacity

Photo by Elaine Adolfo http://www.fotopedia.com/items/flickr-469125880

Page 4: SOLID and Better Design

Design Smells

1. Rigidity2. Fragility3. Immobility4. Viscosity5. Needless Complexity6. Needless repetition7. Opacity

The system is hard to change because every change forces many other changes to other parts of the system.

Page 5: SOLID and Better Design

Design Smells

1. Rigidity2. Fragility3. Immobility4. Viscosity5. Needless Complexity6. Needless repetition7. Opacity

Changes cause the system to break in places that have no conceptual relationship to the part that was changed.

Page 6: SOLID and Better Design

Design Smells

1. Rigidity2. Fragility3. Immobility4. Viscosity5. Needless Complexity6. Needless repetition7. Opacity

It is hard to disentangle the system into components that ca be reused in other systems.

Page 7: SOLID and Better Design

Design Smells

1. Rigidity2. Fragility3. Immobility4. Viscosity5. Needless Complexity6. Needless repetition7. Opacity

Doing things right is harder than doind things wrong.

Page 8: SOLID and Better Design

Design Smells

1. Rigidity2. Fragility3. Immobility4. Viscosity5. Needless Complexity6. Needless repetition7. Opacity

The design contains infrastructure that adds no direct benefit.

Page 9: SOLID and Better Design

Design Smells

1. Rigidity2. Fragility3. Immobility4. Viscosity5. Needless Complexity6. Needless repetition7. Opacity

The design contains repeating structures that could be unified under a single abstraction.

Page 10: SOLID and Better Design

Design Smells

1. Rigidity2. Fragility3. Immobility4. Viscosity5. Needless Complexity6. Needless repetition7. Opacity

It is hard to read and understand. It does not express its intent well.

Page 11: SOLID and Better Design

• Cohesion– All responsibilites of a module should be

related and focused.

• Coupling– How much a module depends upon

others

Page 12: SOLID and Better Design

S.O.L.I.D.

• Single Responsibility• Open Closed• Liskov Substitution• Interface Segregation• Dependency Inversion

Photo by Jean Christophe Prunet http://www.fotopedia.com/items/_avPIZmqM3w-vdSxZGLACsg

Page 13: SOLID and Better Design
Page 14: SOLID and Better Design
Page 15: SOLID and Better Design

Single Responsibility Principle

• One class should have only one reason to change.

• One responsability, one reason to change

Page 16: SOLID and Better Design
Page 17: SOLID and Better Design

Open Closed Principle

• Open for extension• Closed for modification

• Design modules to never change.• A change should impact only one

module.• Abstraction

Page 18: SOLID and Better Design
Page 19: SOLID and Better Design

Liskov Substitution Principle

• If you use a class, you should be able to use its base class.

Page 20: SOLID and Better Design
Page 21: SOLID and Better Design

Interface Segregation Principle

• Clients should not be obliged to depend upon interfaces they not use

Page 22: SOLID and Better Design
Page 23: SOLID and Better Design

Dependency Injection Principle

• Higher level modules should not depend upon low level modules

Page 24: SOLID and Better Design

4 rules of simple design

1. Runs all the tests2. Contains no duplication3. Expresses the intent of the

programmer4. Minimizes the number of classes

and methods

Kent Beck

Page 25: SOLID and Better Design

Summary

Page 26: SOLID and Better Design

Read More

Page 27: SOLID and Better Design

References

• http://www.slideshare.net/JuanjoFuchs/solid-cmo-lo-aplico-a-mi-cdigo

• SOLID Development by Chris Deweese http://www.slideshare.net/cdeweese/solid-development

• SOLID Design Principles by Bruno Bossola http://www.slideshare.net/bbossola/geecon09-solid

• Solid Development Practices in Motivational Pictures http://lostechies.com/derickbailey/2009/02/11/solid-development-principles-in-motivational-pictures/

Page 28: SOLID and Better Design

Toni Tassani

Toni Tassani

@atassani

http://alapamui.blogspot.com

Barcelona -

Moltes Gràcies(Thank you very much)