SOLID Object Oriented Design Craig Berntson

Slides:



Advertisements
Similar presentations
Object Oriented Design Principles Arnon Rotem-Gal-Oz Product Line Architect.
Advertisements

Design Principles & Patterns
Since 1995, we’ve been building innovative custom solutions specifically designed to meet the unique needs of America’s most recognized companies. If you.
St Louis Day of.NET 2011 Refactoring to a SOLID Foundation Steve Bohlen Senior Software Engineer SpringSource/VMware Blog:
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
Unit Testing ASP.Net MVC
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.
1 Software Maintenance and Evolution CSSE 575: Session 6, Part 1 The “SEAM” Model Steve Chenoweth Office Phone: (812) Cell: (937)
TEST-1 7. Object-Oriented Design Principles. TEST-2 The Pillars of the Paradigm Abstraction Encapsulation Hierarchy –Association, Aggregation –Inheritance.
Craig Berntson
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”.
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,
Software Engineering. Administrivia This is me: Cyndi Rader You can reach me: Or find me here: BB 280D Class notes here:
OODP Prudent OO Design. OODP-2 The Pillars of the Paradigm Abstraction Encapsulation Hierarchy –Association, Aggregation –Inheritance Polymorphism.
© 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)
Башкирцев (Старовер) Станислав JavaTalks OOD Principles.
SOLID Principles in Software Design
SWE © Solomon Seifu ELABORATION. SWE © Solomon Seifu Lesson 12-5 Software Engineering Design Goals.
Design Principles iwongu at gmail dot com.
 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.
REFACTORINGREFACTORING. Realities Code evolves substantially during development Requirements changes 1%-4% per month on a project Current methodologies.
OO Design Principles Copyright © Vyacheslav Mukhortov, Nikita Nyanchuk-Tatarskiy, Copyright © INTEKS LLC,
Software Design Patterns Curtsy: Fahad Hassan (TxLabs)
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,
High Cohesion Low Coupling Old Standards for Object Oriented Programming.
Five design principles
CHAPTER 3 MODELING COMPONENT-LEVEL DESIGN.
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.
SOLID Design Principles
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided with permission by.
SOLID Principles in Software Design
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.
SOLID PHP & Code Smell Wrap-Up
Microsoft Advertising 16:9 Template Light Use the slides below to start the design of your presentation. Additional slides layouts (title slides, tile.
Beginning Software Craftsmanship Brendan Enrick Steve Smith
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
CMPE 135: Object-Oriented Analysis and Design October 24 Class Meeting
Copyright © by Curt Hill
object oriented Principles of software design
Object Oriented Practices
Software Design Principles
lecture 08, OO Design Principle
11/29/2018 © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks.
Design Tips.
15 letters that will change your code
CMPE 135 Object-Oriented Analysis and Design March 21 Class Meeting
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
Interface Segregation Principle
Presentation transcript:

SOLID Object Oriented Design Craig Berntson

A little about me  Independent consultant in Salt Lake City  Currently developing database software for sale to hospitals  Microsoft MVP  INETA Community Speaker  Author

Today’s session  Review basic OOP and smells  SOLID principles  Other agile/OOP principles

Basic OOP  Polymorphism  Encapsulation  Inheritance  Cohesion  Coupling

Refactoring code smells  Duplicate code  Long method  Large class  Temporary field  Switch statements  Parallel inheritance hierarchies

Design smells  Rigidity  Software is difficult to change  Fragility  Program breaks in many places when a change made in a single place  Immobility  Parts could be useful in other systems, but effort and risk to separate from original system is too great

Design smells  Viscosity  Design-preserving methods are more difficult to use than the hacks  Development environment is slow and inefficient  Needless complexity  Contains elements that aren’t currently useful  Needless repetition  System has lots of repeated code elements  Opacity  A module is difficult to understand

Why does software rot?  Waterfall methodology  Requirements change  Code wants to be chaotic  We don’t take time to refactor  We suck at OO design  Designs and practices are at fault

Technical Debt  The cost to fix rotting code  Interest charges build over time  The longer we take to remove the smells, the more it will cost

SOLID  Single Responsibility Principle (SRP)  Open-Closed Principle (OCP)  Liskov Substitution Principle (LSP)  Interface Segregation Principle (ISP)  Dependency Inversion Principle (DIP)

Where does SOLID come from?

Jenga

A real example

Single Responsibility Principle (SRP) A class should have only one reason to change

Responsibility  What a class does  The more a class does, the more likely it will change  The more a class changes, the more likely we will introduce bugs

Cohesion and Coupling  Cohesion – How closely related are the different responsibilities of a module  Coupling – How much one module relies on another  Goal is low coupling and high cohesion

EXAMPLE CODE Single Responsibility Principle

Demo  Single Responsibility Principle

Open Closed principle (OCP) Software entities (classes, modules, functions, etc.) should be open for extension but closed for modification

Conforming to OCP  Open for extension  Behavior of the module can be extended  We are able to change what the module does  Closed for modification  Extending behavior does not result in changes to source, binary, or code of the module

Does not conform to OCP Client is not open and closed

Strategy pattern Client is both open and closed

Conforming to OCP  Rely on abstractions  Interfaces  Abstract classes

EXAMPLE CODE Open Closed Principle

Liskov Substitution Principle (LSP) Subtypes must be substitutable for their base types

IS-A  Basic OOP discusses inheritance with “IS-A”  LSP says that “IS-A” refers to behavior  Behavior is what software is really all about

Substitution  Calling code should not know that one module is different from its substitute

EXAMPLE CODE Liskov Substitution Principle

Interface Segregation Principle (ISP) Clients should not be forced to depend on methods they do not use

EXAMPLE CODE Interface Segregation Principle

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

EXAMPLE CODE Dependency Inversion Principle

Other principles  Keep It Simple Stupid (KISS)  You Ain’t Gonna Need It (YAGNI)  Don’t Repeat Yourself (DRY)

Today’s session  Review basic OOP and smells  Single Responsibility Principle (SRP)  Open-Closed Principle (OCP)  Liskov Substutution Principle (LSP)  Interface Segregation Principle (ISP)  Dependency Inversion Principle (DIP)  Other agile/OOP principles

Questions?  Motivational posters courtesy of Derick Bailey through the Creative Commons License  Contact me   Blog: 