SlideShare ist ein Scribd-Unternehmen logo
1 von 35
Learning Session’s

      Object Oriented Life
          VIVEK.P.S
Welcome and Introduction

   The subject of the session.
   The overall goals of the session.
Overview

   Overview of the OOP’S.
    Why this is important for you.
   Class design principles
   C# and OOP’s
Vocabulary

   SRP: Single Responsibility Principle.
   OCP: Open/Closed Principle.
   LSP: Liskov Substitution Principle.
   ISP: Interface Segregation Principle.
   DIP: Dependency Inversion Principle.
Single Responsibility Principle
Single Responsibility Principle

   A responsibility is considered to be one
    reason to change a class.
   if we have 2 reasons to change for a
    class, we have to split the functionality
    in two classes.
   A class should have only one reason to
    change.
Single Responsibility Principle

   bad example-Protocol,Content change
    interface IEmail {
    public void setSender(String sender);
    public void setReceiver(String receiver);
    public void setContent(String content);
    }

    class Email implements IEmail {
    public void setSender(String sender) {// set sender; }
    public void setReceiver(String receiver) {// set receiver; }
    public void setContent(String content) {// set content; }
    }
Single Responsibility Principle

    good example
    interface IEmail {
    public void setSender(String sender);
    public void setReceiver(String receiver);
    public void setContent(IContent content);
    }
    interface Content {
    public String getAsString(); // used for serialization
    }
    class Email implements IEmail {
    public void setSender(String sender) {// set sender; }
    public void setReceiver(String receiver) {// set receiver; }
    public void setContent(IContent content) {// set content; }
    }
Single Responsibility Principle

   A new interface and class called
    IContent and Content to split the
    responsibilities.
   Adding a new protocol causes changes
    only in the Email class.
   Adding a new type of content
    supported causes changes only in
    Content class.
Open Close Principle
Open Close Principle

   Software entities like classes, modules
    and functions should be open for
    extension but closed for
    modifications.
   that the behavior of the module can be
    extended.we can make the module
    behave in new and different ways as
    the requirements of the application.
Open Close Principle

   They are “Closed for Modification”.
   The source code of such a module is
    inviolate. No one is allowed to make
    source
   Abstraction is the key principle.
-   Bad example
    class GraphicEditor {
    public void drawShape(Shape s) {
    if (s.m_type==1)
            drawRectangle(s);
    else if (s.m_type==2)
            drawCircle(s);
    }
    public void drawCircle(Circle r) {....}
    public void drawRectangle(Rectangle r) {....}
    }

    class Shape {
    int m_type;
    }

    class Rectangle extends Shape {
    Rectangle() {
    super.m_type=1;
    }
    }

    class Circle extends Shape {
    Circle() {
    super.m_type=2;
    }
    }
Open Close Principle
Open Close Principle

    Good example
    class GraphicEditor {
    public void drawShape(Shape s) {
    s.draw();
    }
    }
    class Shape {
    abstract void draw();
    }
    class Rectangle extends Shape {
    public void draw() {
    // draw the rectangle
    }
    }
Open Close Principle
Liskov's Substitution Principle
Liskov's Substitution Principle

   Derived types must be completely
    substitutable for their base types.
   if a program module is using a Base
    class, then the reference to the Base
    class can be replaced with a Derived
    class without affecting the functionality
    of the program module.
// Violation of Likov's Substitution Principle
class Rectangle {
     protected int m_width;
     protected int m_height;
     public void setWidth(int width)
          { m_width = width; }
     public void setHeight(int height)
          { m_height = height; }
     public int getArea()
          { return m_width * m_height; }
 }
 class Square extends Rectangle {
    public void setWidth(int width)
          { m_width = width; m_height = width; }
     public void setHeight(int height)
    { m_width = height; m_height = height; }

}
class LspTest {
    private static Rectangle getNewRectangle()
    {
          // it can be an object returned by some factory ...
          return new Square();
    }
    public static void main (String args[])
    {
          Rectangle r = LspTest.getNewRectangle();
          r.setWidth(5);
          r.setHeight(10);
          // user knows that r it's a rectangle.
          // It assumes that he's able to set the width and height as for the
    base class
          System.out.println(r.getArea());
          // now he's surprised to see that the area is 100 instead of 50.
    }
}
Liskov's Substitution Principle

   it means that we must make sure that
    new derived classes are extending the
    base classes without changing their
    behavior.
Interface Segregation Principle
Interface Segregation Principle

   clients should not be forced to
    implement interfaces they don't use.
// interface segregation principle - bad example
interface IWorker {
    public void work();
    public void eat();
}
class Worker implements IWorker{
    public void work() {}
    public void eat() {}
}
class Robot implements IWorker{
    public void work() {}
    public void eat() {}
}
class Manager {
    IWorker worker;
    public void setWorker(IWorker w) { }
    public void manage() {
          worker.work(); } }
// interface segregation principle - good example
interface IWorkable {
    public void work();
}

interface IFeedable{
    public void eat();
}

class Worker implements IWorkable, IFeedable{
    public void work() {}
    public void eat() {}

}

class Robot implements IWorkable{
    public void work() {}
}
Dependency Inversion Principle
Dependency Inversion Principle

   High-level modules should not depend
    on low-level modules. Both should
    depend on abstractions Give an
    example.
   Abstractions should not depend on
    details. Details should depend on
    abstractions
Dependency Inversion Principle




   3 modules, Copy module call other 2
    modules.2 sub modules are re usable
Dependency Inversion Principle

void Copy()
{
int c;
while ((c = ReadKeyboard()) != EOF)
WritePrinter(c);
}
Dependency Inversion Principle

enum OutputDevice {printer, disk};
void Copy(outputDevice dev)
{
int c;
while ((c = ReadKeyboard()) != EOF)
if (dev == printer)
WritePrinter(c);
else
WriteDisk(c);
}
   New device disk
Dependency Inversion Principle

   Make Copy module re usable.
class Reader
{
public:
virtual int Read() = 0;
};
class Writer
{
public:
virtual void Write(char) = 0;
};
void Copy(Reader& r, Writer& w)
{
int c;
while((c=r.Read()) != EOF)
w.Write(c);
}
Summary
   SRP: One reason to change.
   OCP: Extend function with out editing
    code.
   LSP: Derived types can substitute
    base.
   ISP: Don’t implement Interface they
    don’t use
   DIP: Depend on abstraction instead of
    details.
C# oop’s

  Refreshing of what you know..
More information

   http://vivekcek.wordpress.com.

Weitere ähnliche Inhalte

Was ist angesagt?

Java OOP Programming language (Part 6) - Abstract Class & Interface
Java OOP Programming language (Part 6) - Abstract Class & InterfaceJava OOP Programming language (Part 6) - Abstract Class & Interface
Java OOP Programming language (Part 6) - Abstract Class & InterfaceOUM SAOKOSAL
 
Poster on Automated Refactoring of Legacy Java Software to Default Methods
Poster on Automated Refactoring of Legacy Java Software to Default MethodsPoster on Automated Refactoring of Legacy Java Software to Default Methods
Poster on Automated Refactoring of Legacy Java Software to Default MethodsRaffi Khatchadourian
 
Abstract Class & Abstract Method in Core Java
Abstract Class & Abstract Method in Core JavaAbstract Class & Abstract Method in Core Java
Abstract Class & Abstract Method in Core JavaMOHIT AGARWAL
 
Automated Refactoring of Legacy Java Software to Default Methods Talk at GMU
Automated Refactoring of Legacy Java Software to Default Methods Talk at GMUAutomated Refactoring of Legacy Java Software to Default Methods Talk at GMU
Automated Refactoring of Legacy Java Software to Default Methods Talk at GMURaffi Khatchadourian
 
Ppt on this and super keyword
Ppt on this and super keywordPpt on this and super keyword
Ppt on this and super keywordtanu_jaswal
 
Java abstract class & abstract methods
Java abstract class & abstract methodsJava abstract class & abstract methods
Java abstract class & abstract methodsShubham Dwivedi
 
Design principles - SOLID
Design principles - SOLIDDesign principles - SOLID
Design principles - SOLIDPranalee Rokde
 
Interface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar SinghInterface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar Singhdheeraj_cse
 
Abstract Class Presentation
Abstract Class PresentationAbstract Class Presentation
Abstract Class Presentationtigerwarn
 
Template Method Pattern
Template Method PatternTemplate Method Pattern
Template Method Patternmonisiqbal
 
Lecture 9 access modifiers and packages
Lecture   9 access modifiers and packagesLecture   9 access modifiers and packages
Lecture 9 access modifiers and packagesmanish kumar
 

Was ist angesagt? (20)

Java OOP Programming language (Part 6) - Abstract Class & Interface
Java OOP Programming language (Part 6) - Abstract Class & InterfaceJava OOP Programming language (Part 6) - Abstract Class & Interface
Java OOP Programming language (Part 6) - Abstract Class & Interface
 
Poster on Automated Refactoring of Legacy Java Software to Default Methods
Poster on Automated Refactoring of Legacy Java Software to Default MethodsPoster on Automated Refactoring of Legacy Java Software to Default Methods
Poster on Automated Refactoring of Legacy Java Software to Default Methods
 
Abstract Class & Abstract Method in Core Java
Abstract Class & Abstract Method in Core JavaAbstract Class & Abstract Method in Core Java
Abstract Class & Abstract Method in Core Java
 
Inheritance
InheritanceInheritance
Inheritance
 
Automated Refactoring of Legacy Java Software to Default Methods Talk at GMU
Automated Refactoring of Legacy Java Software to Default Methods Talk at GMUAutomated Refactoring of Legacy Java Software to Default Methods Talk at GMU
Automated Refactoring of Legacy Java Software to Default Methods Talk at GMU
 
javainterface
javainterfacejavainterface
javainterface
 
Function overloading
Function overloadingFunction overloading
Function overloading
 
07. Virtual Functions
07. Virtual Functions07. Virtual Functions
07. Virtual Functions
 
Ppt on this and super keyword
Ppt on this and super keywordPpt on this and super keyword
Ppt on this and super keyword
 
Java abstract class & abstract methods
Java abstract class & abstract methodsJava abstract class & abstract methods
Java abstract class & abstract methods
 
Design principles - SOLID
Design principles - SOLIDDesign principles - SOLID
Design principles - SOLID
 
Oops
OopsOops
Oops
 
Class and object
Class and objectClass and object
Class and object
 
Structure in c#
Structure in c#Structure in c#
Structure in c#
 
Interface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar SinghInterface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar Singh
 
Abstract Class Presentation
Abstract Class PresentationAbstract Class Presentation
Abstract Class Presentation
 
Template Method Pattern
Template Method PatternTemplate Method Pattern
Template Method Pattern
 
Abstract class
Abstract classAbstract class
Abstract class
 
Lecture 9 access modifiers and packages
Lecture   9 access modifiers and packagesLecture   9 access modifiers and packages
Lecture 9 access modifiers and packages
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructors
 

Andere mochten auch

Out of Autoclave Tooling
Out of Autoclave ToolingOut of Autoclave Tooling
Out of Autoclave ToolingGregleidig
 
Introducing Akvo, an open data startup
Introducing Akvo, an open data startupIntroducing Akvo, an open data startup
Introducing Akvo, an open data startupAkvo_slideshare
 
Professional Learning Plan
Professional Learning PlanProfessional Learning Plan
Professional Learning Plansaraperrin
 
Automotive Exteriors
Automotive ExteriorsAutomotive Exteriors
Automotive ExteriorsGregleidig
 
Practica estadistica proba
Practica estadistica probaPractica estadistica proba
Practica estadistica probaMV Nichox Vega
 
Akvo Track Day Nairobi - An Introduction to Akvo
Akvo Track Day Nairobi - An Introduction to AkvoAkvo Track Day Nairobi - An Introduction to Akvo
Akvo Track Day Nairobi - An Introduction to AkvoAkvo_slideshare
 
Precision Tooling for Composite Processes
Precision Tooling for Composite ProcessesPrecision Tooling for Composite Processes
Precision Tooling for Composite ProcessesGregleidig
 

Andere mochten auch (10)

Out of Autoclave Tooling
Out of Autoclave ToolingOut of Autoclave Tooling
Out of Autoclave Tooling
 
Introducing Akvo, an open data startup
Introducing Akvo, an open data startupIntroducing Akvo, an open data startup
Introducing Akvo, an open data startup
 
Professional Learning Plan
Professional Learning PlanProfessional Learning Plan
Professional Learning Plan
 
Automotive Exteriors
Automotive ExteriorsAutomotive Exteriors
Automotive Exteriors
 
Practica estadistica proba
Practica estadistica probaPractica estadistica proba
Practica estadistica proba
 
COMMUNITY DEVELOPMENT
COMMUNITY DEVELOPMENTCOMMUNITY DEVELOPMENT
COMMUNITY DEVELOPMENT
 
Akvo Track Day Nairobi - An Introduction to Akvo
Akvo Track Day Nairobi - An Introduction to AkvoAkvo Track Day Nairobi - An Introduction to Akvo
Akvo Track Day Nairobi - An Introduction to Akvo
 
English in social work
English in social workEnglish in social work
English in social work
 
Precision Tooling for Composite Processes
Precision Tooling for Composite ProcessesPrecision Tooling for Composite Processes
Precision Tooling for Composite Processes
 
Highrise workshop
Highrise workshopHighrise workshop
Highrise workshop
 

Ähnlich wie Object Oriented Principle’s

The maze of Design Patterns & SOLID Principles
The maze of Design Patterns & SOLID PrinciplesThe maze of Design Patterns & SOLID Principles
The maze of Design Patterns & SOLID PrinciplesMuhammad Raza
 
Structural pattern 3
Structural pattern 3Structural pattern 3
Structural pattern 3Naga Muruga
 
principles of object oriented class design
principles of object oriented class designprinciples of object oriented class design
principles of object oriented class designNeetu Mishra
 
Exception handling and packages.pdf
Exception handling and packages.pdfException handling and packages.pdf
Exception handling and packages.pdfKp Sharma
 
An Introduction to the SOLID Principles
An Introduction to the SOLID PrinciplesAn Introduction to the SOLID Principles
An Introduction to the SOLID PrinciplesAttila Bertók
 
Andrei Iacob - SOLID: Strategies for Implementing Object–Oriented Design Prin...
Andrei Iacob - SOLID: Strategies for Implementing Object–Oriented Design Prin...Andrei Iacob - SOLID: Strategies for Implementing Object–Oriented Design Prin...
Andrei Iacob - SOLID: Strategies for Implementing Object–Oriented Design Prin...Constanța Developers
 
oops with java modules i & ii.ppt
oops with java modules i & ii.pptoops with java modules i & ii.ppt
oops with java modules i & ii.pptrani marri
 
Object Design - Part 1
Object Design - Part 1Object Design - Part 1
Object Design - Part 1Dhaval Dalal
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design PrinciplesAndreas Enbohm
 
Polymorphism, Abstarct Class and Interface in C#
Polymorphism, Abstarct Class and Interface in C#Polymorphism, Abstarct Class and Interface in C#
Polymorphism, Abstarct Class and Interface in C#Umar Farooq
 
Lecture 5 interface.pdf
Lecture  5 interface.pdfLecture  5 interface.pdf
Lecture 5 interface.pdfAdilAijaz3
 
Polymorphism in C# Function overloading in C#
Polymorphism in C# Function overloading in C#Polymorphism in C# Function overloading in C#
Polymorphism in C# Function overloading in C#Abid Kohistani
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Javabackdoor
 

Ähnlich wie Object Oriented Principle’s (20)

The maze of Design Patterns & SOLID Principles
The maze of Design Patterns & SOLID PrinciplesThe maze of Design Patterns & SOLID Principles
The maze of Design Patterns & SOLID Principles
 
Structural pattern 3
Structural pattern 3Structural pattern 3
Structural pattern 3
 
principles of object oriented class design
principles of object oriented class designprinciples of object oriented class design
principles of object oriented class design
 
Exception handling and packages.pdf
Exception handling and packages.pdfException handling and packages.pdf
Exception handling and packages.pdf
 
SOLID
 SOLID SOLID
SOLID
 
An Introduction to the SOLID Principles
An Introduction to the SOLID PrinciplesAn Introduction to the SOLID Principles
An Introduction to the SOLID Principles
 
Andrei Iacob - SOLID: Strategies for Implementing Object–Oriented Design Prin...
Andrei Iacob - SOLID: Strategies for Implementing Object–Oriented Design Prin...Andrei Iacob - SOLID: Strategies for Implementing Object–Oriented Design Prin...
Andrei Iacob - SOLID: Strategies for Implementing Object–Oriented Design Prin...
 
oops with java modules i & ii.ppt
oops with java modules i & ii.pptoops with java modules i & ii.ppt
oops with java modules i & ii.ppt
 
Object Design - Part 1
Object Design - Part 1Object Design - Part 1
Object Design - Part 1
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design Principles
 
SOLID
SOLIDSOLID
SOLID
 
Java interface
Java interfaceJava interface
Java interface
 
Polymorphism, Abstarct Class and Interface in C#
Polymorphism, Abstarct Class and Interface in C#Polymorphism, Abstarct Class and Interface in C#
Polymorphism, Abstarct Class and Interface in C#
 
Lecture 5 interface.pdf
Lecture  5 interface.pdfLecture  5 interface.pdf
Lecture 5 interface.pdf
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Design pattern
Design patternDesign pattern
Design pattern
 
Polymorphism in C# Function overloading in C#
Polymorphism in C# Function overloading in C#Polymorphism in C# Function overloading in C#
Polymorphism in C# Function overloading in C#
 
L22 Design Principles
L22 Design PrinciplesL22 Design Principles
L22 Design Principles
 
Design for Testability
Design for TestabilityDesign for Testability
Design for Testability
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
 

Mehr von vivek p s

Conversational UI Bot Framework
Conversational UI Bot FrameworkConversational UI Bot Framework
Conversational UI Bot Frameworkvivek p s
 
Microsoft Bot Framework
Microsoft Bot FrameworkMicrosoft Bot Framework
Microsoft Bot Frameworkvivek p s
 
Azure functions
Azure functionsAzure functions
Azure functionsvivek p s
 
Cloud computing Azure
Cloud computing AzureCloud computing Azure
Cloud computing Azurevivek p s
 
Object oriented java script
Object oriented java scriptObject oriented java script
Object oriented java scriptvivek p s
 
Surya namskar
Surya namskarSurya namskar
Surya namskarvivek p s
 

Mehr von vivek p s (6)

Conversational UI Bot Framework
Conversational UI Bot FrameworkConversational UI Bot Framework
Conversational UI Bot Framework
 
Microsoft Bot Framework
Microsoft Bot FrameworkMicrosoft Bot Framework
Microsoft Bot Framework
 
Azure functions
Azure functionsAzure functions
Azure functions
 
Cloud computing Azure
Cloud computing AzureCloud computing Azure
Cloud computing Azure
 
Object oriented java script
Object oriented java scriptObject oriented java script
Object oriented java script
 
Surya namskar
Surya namskarSurya namskar
Surya namskar
 

Kürzlich hochgeladen

Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 

Kürzlich hochgeladen (20)

Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 

Object Oriented Principle’s

  • 1. Learning Session’s Object Oriented Life VIVEK.P.S
  • 2. Welcome and Introduction  The subject of the session.  The overall goals of the session.
  • 3. Overview  Overview of the OOP’S.  Why this is important for you.  Class design principles  C# and OOP’s
  • 4. Vocabulary  SRP: Single Responsibility Principle.  OCP: Open/Closed Principle.  LSP: Liskov Substitution Principle.  ISP: Interface Segregation Principle.  DIP: Dependency Inversion Principle.
  • 6. Single Responsibility Principle  A responsibility is considered to be one reason to change a class.  if we have 2 reasons to change for a class, we have to split the functionality in two classes.  A class should have only one reason to change.
  • 7. Single Responsibility Principle  bad example-Protocol,Content change interface IEmail { public void setSender(String sender); public void setReceiver(String receiver); public void setContent(String content); } class Email implements IEmail { public void setSender(String sender) {// set sender; } public void setReceiver(String receiver) {// set receiver; } public void setContent(String content) {// set content; } }
  • 8. Single Responsibility Principle  good example interface IEmail { public void setSender(String sender); public void setReceiver(String receiver); public void setContent(IContent content); } interface Content { public String getAsString(); // used for serialization } class Email implements IEmail { public void setSender(String sender) {// set sender; } public void setReceiver(String receiver) {// set receiver; } public void setContent(IContent content) {// set content; } }
  • 9. Single Responsibility Principle  A new interface and class called IContent and Content to split the responsibilities.  Adding a new protocol causes changes only in the Email class.  Adding a new type of content supported causes changes only in Content class.
  • 11. Open Close Principle  Software entities like classes, modules and functions should be open for extension but closed for modifications.  that the behavior of the module can be extended.we can make the module behave in new and different ways as the requirements of the application.
  • 12. Open Close Principle  They are “Closed for Modification”.  The source code of such a module is inviolate. No one is allowed to make source  Abstraction is the key principle.
  • 13. - Bad example class GraphicEditor { public void drawShape(Shape s) { if (s.m_type==1) drawRectangle(s); else if (s.m_type==2) drawCircle(s); } public void drawCircle(Circle r) {....} public void drawRectangle(Rectangle r) {....} } class Shape { int m_type; } class Rectangle extends Shape { Rectangle() { super.m_type=1; } } class Circle extends Shape { Circle() { super.m_type=2; } }
  • 15. Open Close Principle  Good example class GraphicEditor { public void drawShape(Shape s) { s.draw(); } } class Shape { abstract void draw(); } class Rectangle extends Shape { public void draw() { // draw the rectangle } }
  • 18. Liskov's Substitution Principle  Derived types must be completely substitutable for their base types.  if a program module is using a Base class, then the reference to the Base class can be replaced with a Derived class without affecting the functionality of the program module.
  • 19. // Violation of Likov's Substitution Principle class Rectangle { protected int m_width; protected int m_height; public void setWidth(int width) { m_width = width; } public void setHeight(int height) { m_height = height; } public int getArea() { return m_width * m_height; } } class Square extends Rectangle { public void setWidth(int width) { m_width = width; m_height = width; } public void setHeight(int height) { m_width = height; m_height = height; } }
  • 20. class LspTest { private static Rectangle getNewRectangle() { // it can be an object returned by some factory ... return new Square(); } public static void main (String args[]) { Rectangle r = LspTest.getNewRectangle(); r.setWidth(5); r.setHeight(10); // user knows that r it's a rectangle. // It assumes that he's able to set the width and height as for the base class System.out.println(r.getArea()); // now he's surprised to see that the area is 100 instead of 50. } }
  • 21. Liskov's Substitution Principle  it means that we must make sure that new derived classes are extending the base classes without changing their behavior.
  • 23. Interface Segregation Principle  clients should not be forced to implement interfaces they don't use.
  • 24. // interface segregation principle - bad example interface IWorker { public void work(); public void eat(); } class Worker implements IWorker{ public void work() {} public void eat() {} } class Robot implements IWorker{ public void work() {} public void eat() {} } class Manager { IWorker worker; public void setWorker(IWorker w) { } public void manage() { worker.work(); } }
  • 25. // interface segregation principle - good example interface IWorkable { public void work(); } interface IFeedable{ public void eat(); } class Worker implements IWorkable, IFeedable{ public void work() {} public void eat() {} } class Robot implements IWorkable{ public void work() {} }
  • 27. Dependency Inversion Principle  High-level modules should not depend on low-level modules. Both should depend on abstractions Give an example.  Abstractions should not depend on details. Details should depend on abstractions
  • 28. Dependency Inversion Principle  3 modules, Copy module call other 2 modules.2 sub modules are re usable
  • 29. Dependency Inversion Principle void Copy() { int c; while ((c = ReadKeyboard()) != EOF) WritePrinter(c); }
  • 30. Dependency Inversion Principle enum OutputDevice {printer, disk}; void Copy(outputDevice dev) { int c; while ((c = ReadKeyboard()) != EOF) if (dev == printer) WritePrinter(c); else WriteDisk(c); }  New device disk
  • 31. Dependency Inversion Principle  Make Copy module re usable.
  • 32. class Reader { public: virtual int Read() = 0; }; class Writer { public: virtual void Write(char) = 0; }; void Copy(Reader& r, Writer& w) { int c; while((c=r.Read()) != EOF) w.Write(c); }
  • 33. Summary  SRP: One reason to change.  OCP: Extend function with out editing code.  LSP: Derived types can substitute base.  ISP: Don’t implement Interface they don’t use  DIP: Depend on abstraction instead of details.
  • 34. C# oop’s Refreshing of what you know..
  • 35. More information  http://vivekcek.wordpress.com.