Saturday, 1 March 2014

SOLID Principles of Object Oriented Design

 

 

The Single Responsibility Principle

 

image

 

 

 

image

 

 

 

image

 

 

 

image

 

 

 

DEMO:  The Problem

 

In this class diagram, Rectangle class depends on GUI library package.  Same way Graphical Application and Geometry Service are using Rectangle Class.  If anything changes on GUI  will affect the Rectangle class, hence it should be compiled likewise Geometry services and Graphical Application should be compiled.

 

image

 

 

 

The problem in Business Implementation

image

 

 

 

image

 

 

 

Problem Analysis

image

 

 

 

Refactoring Better Design

 

image

 

 

image

 

 

image

 

 

image

 

 

image

 

 

image

 

 

 

 

 

The Open / Closed Principle

 

image

 

 

 

image

 

 

 

image

 

 

 

image

 

 

 

DEMO:  The Problem

 

image

 

 

image

 

 

 

The problem Analysis

 

image

 

 

 

image

 

 

 

Refactoring to a Better Design

 

image

 

 

 

image

 

 

 

image

 

 

image

 

 

image

 

 

image

 

 

image

 

 

image

 

 

Adding New rule easily

image

 

 

image

 

 

 

image

 

 

 

image

 

 

 

 

The Liskov Substitution Principle

 

image

 

 

image

 

 

 

image

 

 

 

image

 

 

 

image

 

 

 

Demo: The Problem

image

 

 

image

 

 

image

 

 

image

 

 

 

image

 

 

 

image

 

 

image

 

 

 

Refactoring to a Better Design

image

 

 

 

image

 

 

 

image

 

 

image

 

 

 

 

The Interface Segregation Principle

 

image

 

 

 

image

 

 

 

image

 

 

 

DEMO:  The problem

 

Problem 1:

image

 

 

image

 

Note:  In order to use Validate method inside of membership provider, we need to implement all other abstract base members which we do not use.

 

 

Problem 2:

image

 

 

image

 

 

image

 

 

image

 

 

image

 

 

 

Problem Analysis

image

 

 

 

image

 

 

 

Refactoring to a Better Design

image

 

 

image

 

 

image

 

 

image

 

 

image

 

 

image

 

 

image

 

 

 

Design Smells and Tips

image

 

 

 

image

 

 

image

 

 

 

image

 

 

image

 

 

 

 

The Dependency Inversion Principle

 

image

 

 

image

 

 

 

image

 

 

image

 

 

image

 

 

image

 

 

 

DEMO:The Problem

 

image

 

 

image

 

 

image

 

 

image

 

 

image

 

 

image

 

 

 

image

 

 

 

image

 

 

 

Refactoring to a Better Design

image

 

 

 

image

 

 

 

image

 

 

 

image

 

 

 

image

 

 

 

Design Smells

image

 

 

 

image

 

 

 

image

 

 

 

image

 

 

image

 

 

 

 

The Dependency Inversion Principle, Part 2

image

 

 

image

 

 

 

image

 

 

image

 

 

 

image

 

 

 

Traditional Programming

image

 

 

image

 

 

 

Refactoring Class Dependencies

 

First step is need to change the Static method to Instance method.

image

 

 

image

 

 

image

 

 

image

 

 

image

 

 

image

 

 

image

 

 

image

 

 

image

 

 

image

 

image

 

 

 

 

The Don't Repeat Yourself Principle, Part 1

 

image

 

 

 

image

 

 

 

image

 

 

 

Demo App and Analysis

 

image

 

 

image

 

 

image

 

 

image

 

 

 

image

 

 

 

Refactor Magic Strings

image

 

 

 

Refactoring Connection String

 

image

 

image

 

 

image

 

 

image

 

 

 

Refactoring Print Statements

 

image

 

 

image

 

 

 

Refactoring Magic Numbers

image

 

 

image

 

 

 

Refactoring Format Strings

 

image

 

 

image

 

 

 

Refactoring Duplicate Logic

image

 

 

image

 

 

image

 

 

 

 

Refactoring Repeated If-then Logic

 

image

 

 

image

 

image

 

image

 

 

 

 

Refactoring Conditional Polymorphism

 

image

 

 

image

 

 

image

 

 

image

 

 

image

 

 

image

 

 

 

 

The Don't Repeat Yourself Principle, Part 2

 

image

 

 

 

image

 

 

 

Test and Static Cling

 

image

 

 

 

image

 

 

 

Demo of Adding Integration Tests

image

 

 

image

 

 

 

Demo of Adding Unit Tests

 

image

 

 

image

 

 

 

image

 

 

image

 

 

 

Demo of MOCK Objects

 

image

 

 

image

 

 

 

image

 

 

 

 

Principles of Object Oriented Design - The Don't Repeat Yourself Principle, Part 3

 

image

 

 

 

Repeated Execution Pattern

image

 

 

 

Demo of Refactoring using Action of T

 

image

 

 

image

 

 

 

image

 

 

 

Demo of Refactor Data Access

 

image

 

 

image

 

 

image

 

 

 

 

Demo:  Find Duplicate Code – Atomiq

 

image

 

image

 

 

 

Code Generation

image

 

 

 

Repetition in process

 

image

 

 

 

Demo of Automation with MS Build

 

image

 

 

image

 

 

image

 

 

image

 

 

image

 

 

image

 

 

 

Blogger Labels: SOLID,Principles,Object,Design,Single,Principle,DEMO,Problem,diagram,Rectangle,library,Same,Graphical,Application,Geometry,Service,Class,Implementation,Analysis,Better,Open,Liskov,Substitution,Interface,Segregation,Note,Validate,method,membership,provider,Smells,Tips,Dependency,Inversion,Part,Traditional,Dependencies,Static,Instance,Repeat,Yourself,Refactor,Magic,Strings,Connection,Print,Statements,Numbers,Format,Duplicate,Logic,Conditional,Polymorphism,Test,Integration,Tests,Unit,MOCK,Objects,Execution,Pattern,Action,Data,Find,Code,Atomiq,Generation,Repetition,Automation,Build

No comments:

Post a Comment