The SOLID Principles.

Slides:



Advertisements
Similar presentations
Jim McKeeth | Podcast at Delphi.org
Advertisements

Object Oriented Design Principles Arnon Rotem-Gal-Oz Product Line Architect.
Design Principles & Patterns
General OO Concepts and Principles CSE301 University of Sunderland Harry R. Erwin, PhD.
Lecture 9 Improving Software Design CSC301-Winter 2011 – University of Toronto – Department of Computer Science Hesam C. Esfahani
SOLID Object Oriented Design Craig Berntson
17.10 Java Beans Java beans are a framework for creating components in Java. AWT and Swing packages are built within this framework Made to fit in with.
Common mistakes Basic Design Principles David Rabinowitz.
Liskov Substitution Principle
Developed by Reneta Barneva, SUNY Fredonia Component Level Design.
Design Patterns and Principles of Object Oriented Application Development “design patterns are proven techniques used by experienced developers to tackle.
1 OO Design Principles Project Group eXtreme Programming Md. Abul Bashar 07/09/2004.
CLASS DESIGN PRINCIPLES Lecture 2. The quality of the architecture What is a good design? It is the design that at least does not have signs of “bad”.
Advanced Principles I Principles of Object-Oriented Class Design Copyright  by Object Mentor, Inc All Rights Reserved Portions of this material.
1 OO Design Novosoft, 2001 by V. Mukhortov. 2 OO Design Goals  Flexibility Changes must be localized  Maintainability Modules requiring changes can.
Company Confidential – Do Not Duplicate 2 Copyright 2008 McLane Advanced Technologies, LLC S.O.L.I.D. Software Development Achieving Object Oriented Principles,
OODP Prudent OO Design. OODP-2 The Pillars of the Paradigm Abstraction Encapsulation Hierarchy –Association, Aggregation –Inheritance Polymorphism.
Design Design and Software Architecture. The design phase The analysis phase describes what the system should be doing The design phase describes how.
© 2004 Capgemini - All rights reserved SOLID - OO DESIGN PRINCIPLES Andreas Enbohm, Capgemini.
CSE 301 Exam Revision Lecture
Introduction to SOLID Principles. Background Dependency Inversion Principle Single Responsibility Principle Open/Closed Principle Liskov Substitution.
S.O.L.I.D. Software Development 12 January 2010 (Martin Verboon, Patrick Kalkman, Stan Verdiesen)
SWE © Solomon Seifu ELABORATION. SWE © Solomon Seifu Lesson 12-5 Software Engineering Design Goals.
Design Principles iwongu at gmail dot com.
The benefits of SOLID in software development Ruben Agudo Santos (GS-AIS-HR)
 What is SOLID  The S in SOLID  The O in SOLID  The L in SOLID  The I in SOLID  The D in SOLID  Questions.
Software Design Principles
Incremental Design Why incremental design? Goal of incremental design Tools for incremental design  UML diagrams  Design principles  Design patterns.
Elements of OO Abstraction Encapsulation Modularity Hierarchy: Inheritance & Aggregation 4 major/essential elements3 minor/helpful elements Typing Concurrency.
OO Design Principles Copyright © Vyacheslav Mukhortov, Nikita Nyanchuk-Tatarskiy, Copyright © INTEKS LLC,
1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 11a: Component-Level Design Software Engineering: A Practitioner’s Approach, 6/e Chapter.
Design for testability as a way to good coding Simone Chiaretta Architect, Council of the EU December 9 th,
Five design principles
Principles of Object Oriented Design
PRINCIPLES OF OBJECT ORIENTED DESIGN S.O.L.I.D. S.O.L.I.D Principles What is SOLID?  Acrostic of 5 Principles:  The Single Responsibility Principle.
Component Design Elaborating the Design Model. Component Design Translation of the architectural design into a detailed (class-based or module- based)
SOLID Design Principles
Session 33 More on SOLID Steve Chenoweth Office: Moench Room F220 Phone: (812) Chandan Rupakheti Office: Moench.
F-1 © 2007 T. Horton CS 4240 Principles of SW Design More design principles LSP, OCP, DIP, … And another pattern Decorator.
1 Interfaces and Abstract Classes The ability to define the behavior of an object without specifying that behavior is to be implemented Interface class.
SOLID PHP & Code Smell Wrap-Up
Liskov Substitution Principle Jon McBee CLA, CLED, CTD, CPI, LabVIEW Champion.
Microsoft Advertising 16:9 Template Light Use the slides below to start the design of your presentation. Additional slides layouts (title slides, tile.
Clean Code and How to Achieve Zero Defects Jason Jolley Director, Application Development Micro Strategies, Inc.
14 Jul 2005CSE403, Summer'05, Lecture 09 Lecture 09: Fundamental Principles and Best Practices for Software Design Valentin Razmov.
1 Advanced Object- oriented Design – Principles CS320 Fall 2005.
1 Advanced Object-oriented Design – Principles and Patterns OO Design Principles.
Mantas Radzevičius ifm-2/2
What is Agile Design? SRP OCP LSP DIP ISP
Course information Old exam Resit Report Result and walkthrough
Software Design Principles
Software Architecture & Difference from Design
CSE687 - Object Oriented Design class notes Survey of the C++ Programming Language Jim Fawcett Spring 2004.
Copyright © by Curt Hill
Object Oriented Practices
TechEd /17/2018 6:14 PM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered.
Software Design Principles
Subtype Polymorphism, Subtyping vs
Design Tips.
Software Design Lecture : 14.
15 letters that will change your code
Verified Subtyping with Traits and Mixins
Principles of Object-Oriented Design
A (partial) blueprint for dealing with change
Principles of Object-Oriented Design
Object Oriented Design & Analysis
Dependency Inversion principle
Some principles for object oriented design
Liskov Substitution Principle (LSP)
Chapter 10 – Component-Level Design
Presentation transcript:

The SOLID Principles

Context 5 Principles of OO Design ‘Collected’ by Robert Martin (Uncle Bob) early 2000s

Code will change Rigid: Cascade of changes Fragile: Unexpected breakages Immobile: Entangled, can’t reuse Viscous: Hard to do the right thing

Related to dependency management Code will change Rigid: Cascade of changes Fragile: Unexpected breakages Immobile: Entangled, can’t reuse Viscous: Hard to do the right thing Related to dependency management

What we’d like Flexible Robust Reusable ‘Pit of success’

Principles that highlight poor code What we’d like Flexible Robust Reusable ‘Pit of success’ Principles that highlight poor code

Some gotchas Various (competing) definitions Lots of misunderstanding & misconceptions Lots of confusion (eg DIP and DI) Can’t prove adherence, can only prove violation

Single Responsibility Principle

Single Responsibility Principle A module should have one, and only one, reason to change

Single Responsibility Principle public class Account { public bool Withdraw(int amount) … public void Print() … public void Save() … }

Open/Closed Principle

Open/Closed Principle You should be able to extend a module’s behaviour, without modifying it

Open/Closed Principle public class AreaCalculator { public double Area(object[] shapes) double area = 0; foreach (var shape in shapes) if (shape is Rectangle) Rectangle rectangle = (Rectangle) shape; area += rectangle.Width*rectangle.Height; } else Circle circle = (Circle) shape; area += circle.Radius*circle.Radius*Math.PI; return area;

Open/Closed Principle public abstract class Shape { public abstract double Area(); } public class AreaCalculator public double Area(Shape[] shapes) double area = 0; foreach (var shape in shapes) area += shape.Area(); return area;

Liskov Substitution Principle

Liskov Substitution Principle Derived classes must be substitutable for their base classes

Liskov Substitution Principle

Interface Segregation Principle

Interface Segregation Principle Make fine grained interfaces that are client specific

Interface Segregation Principle public interface IMachine { void Print(); void Staple(); void Scan(); void PhotoCopy(); }

Interface Segregation Principle public interface IPrinter { void Print(); } public interface IStapler void Staple(); public interface IScanner void Scan(); public interface IPhotoCopier void PhotoCopy(); public interface IMachine : IPrinter, IStapler, IScanner, IPhotoCopier {}

Dependency Inversion Principle

Dependency Inversion Principle Depend on abstractions, not on concretions

Dependency Inversion Principle High-level modules should not depend on low-level modules. Both should depend on abstractions Abstractions should not depend upon details. Details should depend upon abstractions

Dependency Inversion Principle http://code.tutsplus.com/tutorials/solid-part-4-the-dependency-inversion-principle--net-36872

Dependency Inversion Principle http://code.tutsplus.com/tutorials/solid-part-4-the-dependency-inversion-principle--net-36872

Great Destination Terrible Roadmap Can’t prove adherence, can only prove violation