SOLID as OOP abstraction
Paweł Klimczyk
Gemotial 2016
About me
•Software engineer
•Running Gemotial Software Studio
•Co-organizer ofWrocNET
•Blog: http://blog.klimczyk.pl
•E-mail: pawel@klimczyk.pl
•Twitter: @pwlklm
•GitHub: pawelklimczyk
Software Quality/SOLID
jobesto.com
C#/.NET/BizTalk
netdevelopers.pl
BJJ
What I do
What is OOP ?
•Abstraction
•Encapsulation
•Inheritance
•Polymorphism
OOP (r)evolution
•Simula 67, Smalltalk
•Ada, Lisp
•C#, Java
OOP bad habits- Code Smells
• Duplicate Code
• Long Method
• Comments
• Long Parameter List
• Large Class
• Switch Statements
• Parallel Inheritance Hierarchies
• Conditional Complexity
• Combinitorial Explosion
• Uncommunicative Name
• Dead Code
• Inconsistent Names
• Temporary Field
OOP bad habits - Design Smells
• Alternative Classes with Different
Interfaces
• Primitive ObsessionData Class
• Data Clumps
• Refused Bequest
• Inappropriate Intimacy
• Indecent Exposure
• Feature Envy
• Lazy Class
• Message Chains
• Middle Man
• Divergent Change
• Shotgun Surgery
• Parallel Inheritance Hierarchies
• Incomplete Library Class
• Solution Sprawl
Technical debt trap
•Hard to extend rotten code
•The longer we wait to remove the smells, the
more it will cost
SOLID – the beginning
Michael Feathers Robert C.Martin
Year ~2000
Occam's razor principle
Occam's razor is a problem-solving principle devised by
William of Ockham.The principle states that among
competing hypotheses, the one with the fewest
assumptions should be selected. Other, more complicated
solutions may ultimately prove correct, but—in the
absence of certainty—the fewer assumptions that are
made, the better.
SOLID
•Single Responsibility Principle (SRP)
•Open-Closed Principle (OCP)
•Liskov Substitution Principle (LSP)
•Interface Segregation Principle (ISP)
•Dependency Inversion Principle (DIP)
Single Responsibility Principle (SRP)
A class or similar unit of code should have one responsibility only and, therefore,
only one reason to change.
Single Responsibility Principle (SRP)
Open-Closed Principle (OCP)
You should be able to extend a classes behavior, without modifying it.
Open-Closed Principle (OCP)
Liskov Substitution Principle (LSP)
Derived classes must be substitutable for their base classes.
Liskov Substitution Principle (LSP)
Interface Segregation Principle (ISP)
Make fine grained interfaces that are client specific.
Clients should not be forced to depend upon interfaces that they don't use.
Interface Segregation Principle (ISP)
Dependency Inversion Principle (DIP)
Depend on abstractions, not on concretions.
High level modules should not depend upon low level modules and abstractions
should not depend upon details.
Dependency Inversion Principle (DIP)
Other principles
•Keep It Simple Stupid (KISS)
•You Ain’t Gonna Need It (YAGNI)
•Don’t RepeatYourself (DRY)
References
• http://objectmentor.com/Images/photo_feathers.jpg
• http://upload.wikimedia.org/wikipedia/commons/thumb/e/ee/Robert_Cecil
_Martin.png/220px-Robert_Cecil_Martin.png
• http://www.butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod
• SOLID examples:
• https://msdn.microsoft.com/en-us/magazine/dn683797.aspx
Q&A

Solid as OOP abstraction

Editor's Notes

  • #6 Ole-Johana Dahl and Kristen Nygaard