solid -clean code for mere mortals

22

Upload: wekoslav-stefanovski

Post on 02-Jul-2015

595 views

Category:

Self Improvement


1 download

TRANSCRIPT

Page 1: SOLID -Clean Code For Mere Mortals
Page 2: SOLID -Clean Code For Mere Mortals

SOLIDClean code for mere mortals

Page 3: SOLID -Clean Code For Mere Mortals
Page 4: SOLID -Clean Code For Mere Mortals
Page 5: SOLID -Clean Code For Mere Mortals

{What is software development?

‹ Software development is not (only) programming

‹ Agile Software Development: Principles, Patterns, and Practices

‹ The Pragmatic Programmer

‹ Manifesto for Software Craftsmanship

Page 6: SOLID -Clean Code For Mere Mortals

Software requirements

‹ Notoriously fluid

‹ Changes in scope

‹ Changes in functionalities

‹ Changes in environments

‹ The only constant is change

‹ We should embrace change!

{

Page 7: SOLID -Clean Code For Mere Mortals

{Software Rot

‹ Occurs to any software that survives the first version

‹ Rigidity

‹ Fragility

‹ Immobility

‹ Viscosity

Page 8: SOLID -Clean Code For Mere Mortals

SOLID Principles

‹ Introduced by Robert C. Martin (Uncle Bob)

‹ An acronym of acronyms

‹ Not a piece of code

‹ Tool for “code smell” detection

{

Page 9: SOLID -Clean Code For Mere Mortals

SOLID Principles

‹ Single Responsibility Principle

‹ Open Closed Principle

‹ Liskov Substitution Principle

‹ Interface Segregation Principle

‹ Dependency Inversion Principle

{

Page 10: SOLID -Clean Code For Mere Mortals

SOLID

‹ Single Responsibility Principle

‹ Single Level of abstraction

‹ Just one reason to change

‹ Antithesis of the “God” object

{

Page 11: SOLID -Clean Code For Mere Mortals

SRP IN ACTION

Page 12: SOLID -Clean Code For Mere Mortals

SOLID

‹ Open Closed Principle

‹ Inspired from work on Eiffel

‹ Open for extensions

‹ Closed for modification

‹ Use polymorphic behaviours

{

Page 13: SOLID -Clean Code For Mere Mortals

OCP IN ACTION

Page 14: SOLID -Clean Code For Mere Mortals

SOLID

‹ Liskov Substitution Principle

‹ Named after Barbara Liskov

‹ Subclasses should be substitutable for their base classes.

‹ Design by Contract

‹ A Circle is not an Ellipse

{

Page 15: SOLID -Clean Code For Mere Mortals

LSP IN ACTION

Page 16: SOLID -Clean Code For Mere Mortals

SOLID

‹ Interface Segregation Principle

‹ It’s not always about the `interface` keyword

‹ An interface should have a single purpose

‹ An interface should define a client

{

Page 17: SOLID -Clean Code For Mere Mortals

ISP IN ACTION

Page 18: SOLID -Clean Code For Mere Mortals

SOLID

‹ Dependency Inversion‹ Depend upon abstractions.‹ Do not depend upon concretions.‹ Object creation problems – use

object factories.‹ The principle behind Inversion-of-

control and Dependency Injection

{

Page 19: SOLID -Clean Code For Mere Mortals

DIP IN ACTION

Page 20: SOLID -Clean Code For Mere Mortals

Bonus Principle: YAGNI

‹ You Ain’t Gonna Need It

‹ Just-in-time implementation

‹ Avoid architecture astronauts

‹ Simpler code is easier to refactor

‹ Keep it as simple as possible, but not simpler

{

Page 21: SOLID -Clean Code For Mere Mortals

Questions?• Complete the electronic evaluation

forms on the computers in the hall and enter to win!– Telerik Ultimate Collection– RedGate .NET Reflector VSPro– ComponentOne Enterprise Studio Suite– Pluralsight yearly subscriptions– CodeSmith Tools Generator Pro

Personal– JetBrains ReSharper– Semos Education Training Voucher– and many more…

Page 22: SOLID -Clean Code For Mere Mortals