Refactoring to a SOLID Foundation

53
St Louis Day of .NET 2011 Refactoring to a SOLID Foundation Steve Bohlen Senior Software Engineer SpringSource/VMware E-Mail: [email protected] Blog: http://blog.unhandled-exceptions.com Twitter: @sbohlen

description

Refactoring to a SOLID Foundation. Steve Bohlen Senior Software Engineer SpringSource /VMware E-Mail: [email protected] Blog: http://blog.unhandled-exceptions.com Twitter: @ sbohlen. Sleep is for Wimps!. Indulge Yourself!. Get your LEARN on!. Do I suck?. Let me (and the world) know!. - PowerPoint PPT Presentation

Transcript of Refactoring to a SOLID Foundation

Page 1: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Refactoring to a SOLID Foundation

Steve BohlenSenior Software EngineerSpringSource/VMware

E-Mail: [email protected]: http://blog.unhandled-exceptions.comTwitter: @sbohlen

Page 2: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Sleep is for Wimps!

Page 3: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Indulge Yourself!

Page 4: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Get your LEARN on!

Page 5: Refactoring to a SOLID Foundation
Page 6: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Do I suck?Let me (and the world) know!

http://spkr8.com/t/8095

Page 7: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Who am I?• …and why should you care?• Steve Bohlen• I Read Books + Write Software• vs. “Read Software + Write Books”

• Blog, Screencast, Speak, Share, Learn

Page 8: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Steve BohlenNearly 20 years developing softwareLISP, Delphi, C/C++, VB, VB.NET, C#Senior Engineer Springsource/VMwareCo-Founder, NYC Alt.Net User Group

http://nyalt.netCo-Organizer, NYC DDD User Group

http://dddnyc.orgContributor: various OSS projects

NHibernate http://www.nhforge.orgNDbUnit http://www.googlecode.com/ndbunitSpring.NET http://www.springframework.net

blog: http://blog.unhandled-exceptions.come-mail: [email protected]: @sbohlen

CYND D D

Page 9: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

RAD Controls for ASP.NET AJAX

RAD Controls for Silverlight

RAD Controls for Windows Phone

RAD Controls for Winforms

RAD Controls for WPF

Telerik Reporting

Telerik OpenAccess ORM

Telerik JustCode

Telerik JustMock

Telerik Extensions for ASP.NET MVC

Test Studio Express

Telerik TeamPulse

Telerik Test Studio

Sitefinity CMS

Telerik JustDecompile

C#/VB.NET Converter

ASPX to Razor Converter

Page 10: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Page 11: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Page 12: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Page 13: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Page 14: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Page 15: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Page 16: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Page 17: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Page 18: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Page 19: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

•Disciplined technique•Restructuring an existing body of code•Altering its internal structure without changing its external behavior•A series of small behavior-preserving transformations•Each 'refactoring’ does little by itself•A sequence of transformations can produce a significant restructuring•Each refactoring is small so it's less likely to go wrong•The system is kept fully working after each small refactoring

Refactoring

Page 20: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Page 21: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Refactoring Tools•Developer Express CodeRush

http://devexpress.com/coderush

•JetBrains Resharperhttp://www.jetbrains.com/resharper/

•Telerik JustCodehttp://www.telerik.com/products/justcode.aspx

•Visual Studio Professional

•Notepad!

Page 22: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Page 23: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Introduction to S.O.L.I.D.

SOLID

ingle Responsibility PrincipleRPCPSPSPIP

pen-Close Principle

iskov Substitution Principle

nterface Segregation Principle

ependency Inversion Principle

Page 24: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Introduction to S.O.L.I.D.

SOLID

ingle Responsibility Principle

pen-Close Principle

iskov Substitution Principle

nterface Segregation Principle

ependency Inversion Principle

Page 25: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Page 26: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Single Responsibility Principle

There should never be more than one reason for a class to change.

Page 27: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Refactoring to a S.O.L.I.D. Foundation

SRP Demo

Page 28: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Introduction to S.O.L.I.D.

SOLID

ingle Responsibility Principle

pen-Close Principle

iskov Substitution Principle

nterface Segregation Principle

ependency Inversion Principle

Page 29: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Page 30: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Open-Closed Principle

Software Entities (Classes, Modules, Functions, etc.)should be Open for Extension, but Closed

for Modification.

Page 31: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Refactoring to a S.O.L.I.D. Foundation

OCP Demo

Page 32: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Introduction to S.O.L.I.D.

SOLID

ingle Responsibility Principle

pen-Close Principle

iskov Substitution Principle

nterface Segregation Principle

ependency Inversion Principle

Page 33: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Page 34: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Liskov Substitution Principle

If for each object o1 of type Sthere is an object o2 of type T such thatfor all programs P defined in terms of T,

the behavior of P is unchanged when o1 is substituted for o2, then S is a subtype of T.WTF ?!?

Page 35: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Liskov Substitution Principle

Functions that use pointers or references to base classes must be able to use objects of

derived classes without knowing it.

Page 36: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Refactoring to a S.O.L.I.D. Foundation

LSP Demo

Page 37: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Introduction to S.O.L.I.D.

SOLID

ingle Responsibility Principle

pen-Close Principle

iskov Substitution Principle

nterface Segregation Principle

ependency Inversion Principle

Page 38: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Page 39: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Interface Segregation Principle

Clients should not be forced to depend upon interfaces that they do not use.

Page 40: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Refactoring to a S.O.L.I.D. Foundation

ISP Demo

Page 41: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Introduction to S.O.L.I.D.

SOLID

ingle Responsibility Principle

pen-Close Principle

iskov Substitution Principle

nterface Segregation Principle

ependency Inversion Principle

Page 42: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Page 43: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Dependency Inversion Principle

High Level Modules should not dependupon Low Level Modules. Both should

depend upon abstractions.

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

Page 44: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Refactoring to a S.O.L.I.D. Foundation

DIP Demo

Page 45: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Thinking About Re-Assembly

Presto!

Page 46: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Dependency Injection Frameworks• StructureMap• Spring.NET• Castle Windsor• NInject• Funq• Unity• More…

Page 47: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Refactoring to a S.O.L.I.D. Foundation

Closing Thoughts

Page 48: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Page 49: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Page 50: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Page 51: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Page 52: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

Page 53: Refactoring to a SOLID Foundation

St Louis Day of .NET 2011

fini

Steve BohlenSenior Software EngineerSpringSource/VMware

E-Mail: [email protected]: http://blog.unhandled-exceptions.comTwitter: @sbohlen

http://spkr8.com/t/8095