SlideShare ist ein Scribd-Unternehmen logo
1 von 28
Structural PatternStructural Pattern
Dr. Himanshu Hora
SRMS College of Engineering & Technology
Bareilly (UP) INDIA
Dr. Himanshu Hora
SRMS College of Engineering & Technology
Bareilly (UP) INDIA
01/16/16
Structural Pattern
1
ContentContent
• History of Design Pattern
• Definitions of Design Pattern
• Types of Pattern
• Adapter
• Bridge
• Composite
• Decorator
• Facade
• Flyweight
• Proxy
• Benefits and Possible problems
• History of Design Pattern
• Definitions of Design Pattern
• Types of Pattern
• Adapter
• Bridge
• Composite
• Decorator
• Facade
• Flyweight
• Proxy
• Benefits and Possible problems
01/16/16 Structural Pattern 2
History of Design PatternHistory of Design Pattern
• In 1994, Design Patterns: Elements of Reusable Object-
Oriented Software by Erich Gamma, Richard Helm, Ralph
Johnson and John Vlissides explained the usefulness of
patterns and resulted in the widespread popularity of design
patterns.
• These four authors together are referred to as the Gang of Four
(GoF).
• In 1994, Design Patterns: Elements of Reusable Object-
Oriented Software by Erich Gamma, Richard Helm, Ralph
Johnson and John Vlissides explained the usefulness of
patterns and resulted in the widespread popularity of design
patterns.
• These four authors together are referred to as the Gang of Four
(GoF).
01/16/16 Structural Pattern 3
Definitions of Design PatternDefinitions of Design Pattern
• Design patterns are recurring solutions to software design
problems you find again and again in real-world application
development
OR
• Design patterns represent solutions to problems that arise
when developing software within a particular context
OR
• Design patterns are standard solutions to common problems in
software design
• Design patterns are recurring solutions to software design
problems you find again and again in real-world application
development
OR
• Design patterns represent solutions to problems that arise
when developing software within a particular context
OR
• Design patterns are standard solutions to common problems in
software design
01/16/16 Structural Pattern 4
Types of PatternTypes of Pattern
There are 3 types of pattern
• Creational: address problems of creating an object in a
flexible way. Separate creation, from operation/use.
• Structural: address problems of using O-O constructs like
inheritance to organize classes and objects
• Behavioral: address problems of assigning responsibilities to
classes. Suggest both static relationships and patterns of
communication (use cases)
There are 3 types of pattern
• Creational: address problems of creating an object in a
flexible way. Separate creation, from operation/use.
• Structural: address problems of using O-O constructs like
inheritance to organize classes and objects
• Behavioral: address problems of assigning responsibilities to
classes. Suggest both static relationships and patterns of
communication (use cases)
01/16/16 Structural Pattern 5
Types of PatternTypes of Pattern
Creational Patterns
(concerned with abstracting the object-instantiation process)
• Factory Method Abstract Factory Singleton
• Builder Prototype
Structural Patterns
(concerned with how objects/classes can be combined to form larger
structures)
• Adapter Bridge Composite
• Decorator Facade Flyweight
• Proxy
Behavioral Patterns
(concerned with communication between objects)
• Command Interpreter Iterator
• Mediator Observer State
• Strategy Chain of Responsibility Visitor
• Template Method
Creational Patterns
(concerned with abstracting the object-instantiation process)
• Factory Method Abstract Factory Singleton
• Builder Prototype
Structural Patterns
(concerned with how objects/classes can be combined to form larger
structures)
• Adapter Bridge Composite
• Decorator Facade Flyweight
• Proxy
Behavioral Patterns
(concerned with communication between objects)
• Command Interpreter Iterator
• Mediator Observer State
• Strategy Chain of Responsibility Visitor
• Template Method
01/16/16 Structural Pattern 6
AdapterAdapter
• Convert the interface of a class into another interface clients
expect
• Adapter lets classes work together that couldn't otherwise
because of incompatible interfaces
• Use the Adapter pattern when:
– you want to use an existing class and its interface does not
match the one you need
– you need to use several existing subclasses, but it's
impractical to adapt their interface by subclassing
everyone. An object adapter can adapt the interface of its
parent class
• Convert the interface of a class into another interface clients
expect
• Adapter lets classes work together that couldn't otherwise
because of incompatible interfaces
• Use the Adapter pattern when:
– you want to use an existing class and its interface does not
match the one you need
– you need to use several existing subclasses, but it's
impractical to adapt their interface by subclassing
everyone. An object adapter can adapt the interface of its
parent class
01/16/16 Structural Pattern 7
AdapterAdapter
01/16/16 Structural Pattern 8
BridgeBridge
• Decouple an abstraction from its implementation so that the
two can vary independently
• Use the Bridge pattern when:
– you want run-time binding of the implementation
– you want to share an implementation among multiple
objects
• Decouple an abstraction from its implementation so that the
two can vary independently
• Use the Bridge pattern when:
– you want run-time binding of the implementation
– you want to share an implementation among multiple
objects
01/16/16 Structural Pattern 9
BridgeBridge
01/16/16 Structural Pattern 10
CompositeComposite
• Compose objects into tree structures to represent whole-part
hierarchies. Composite lets clients treat individual objects and
compositions of objects uniformly
• Use this pattern whenever you have "composites that contain
components, each of which could be a composite".
• Compose objects into tree structures to represent whole-part
hierarchies. Composite lets clients treat individual objects and
compositions of objects uniformly
• Use this pattern whenever you have "composites that contain
components, each of which could be a composite".
01/16/16 Structural Pattern 11
CompositeComposite
01/16/16 Structural Pattern 12
DecoratorDecorator
• Attach additional responsibilities to an object dynamically
• Decorators provide a flexible alternative to subclassing for
extending functionality
• Attach additional responsibilities to an object dynamically
• Decorators provide a flexible alternative to subclassing for
extending functionality
01/16/16 Structural Pattern 13
ProblemsProblems
• Several classes with a similar operation (method), but
different behavior.
• We want to use many combinations of these behaviors
• Several classes with a similar operation (method), but
different behavior.
• We want to use many combinations of these behaviors
01/16/16 Structural Pattern 14
Example - Automated HospitalExample - Automated Hospital
• People come to the reception with problems
• They describe their problems
• A special doctoRobot is created that is specialized to treat
their special situations.
• People come to the reception with problems
• They describe their problems
• A special doctoRobot is created that is specialized to treat
their special situations.
01/16/16 Structural Pattern 15
Automated Hospital - Solution 1Automated Hospital - Solution 1
DoctoRobot
Cure (p : Patient)
DentistRobot
Cure (p : Patient)
DermaRobot
Cure (p : Patient)
PsychoRobot
Cure (p : Patient)
DentistDermaRobot DentistPsychoRobot DermaPsychoRobot
01/16/16 Structural Pattern 16
Problems with solution-1Problems with solution-1
• Sometimes we don’t have multiple inheritance.
• Even if we have, if is problematic, and bad design.
• Sometimes we don’t have multiple inheritance.
• Even if we have, if is problematic, and bad design.
01/16/16 Structural Pattern 17
A Better idea: Use DecoratorA Better idea: Use Decorator
ConcreteComponent
Operation( )
ConcreteDecoratorA
addedState
Operation( )
ConcreteDecoratorB
Operation( )
Decorator
Operation( )
Component
Operation( )
component
01/16/16 Structural Pattern 18
Decorator in our caseDecorator in our case
DentistRobot
Cure (p : Patient)
DermaRobot
Cure (p : Patient)
PhsychoRobot
Cure (p : Patient)
DoctorRobotDecorator
innerDoctor
Cure (p : Patient)
DoctoRobot
Cure (p : Patient)
component
01/16/16 Structural Pattern 19
FacadeFacade
• Provide a unified interface to a set of interfaces in a subsystem
• Facade defines a higher-level interface that makes the
subsystem easier to use
• Create a class that is the interface to the subsystem
• Clients interface with the Facade class to deal with the
subsystem
• It hides the implementation of the subsystem from clients
• It promotes weak coupling between the subsystems and its
clients
• It does not prevent clients from using subsystems class, should
it?
• Provide a unified interface to a set of interfaces in a subsystem
• Facade defines a higher-level interface that makes the
subsystem easier to use
• Create a class that is the interface to the subsystem
• Clients interface with the Facade class to deal with the
subsystem
• It hides the implementation of the subsystem from clients
• It promotes weak coupling between the subsystems and its
clients
• It does not prevent clients from using subsystems class, should
it?
01/16/16 Structural Pattern 20
FacadeFacade
01/16/16 Structural Pattern 21
FlyweightFlyweight
• Use sharing to support large numbers of fine-grained objects
efficiently
• The pattern can be used when:
– The program uses a large number of objects and
– The program does not use object identity (==)
• Use sharing to support large numbers of fine-grained objects
efficiently
• The pattern can be used when:
– The program uses a large number of objects and
– The program does not use object identity (==)
01/16/16 Structural Pattern 22
FlyweightFlyweight
01/16/16 Structural Pattern 23
ProxyProxy
• Provide a surrogate or placeholder for another object to
control access to it.
• The proxy has the same interface as the original object
• Virtual Proxy:
– Creates/accesses expensive objects on demand
– You may wish to delay creating an expensive object until it
is really accessed
– It may be too expensive to keep entire state of the object in
memory at one time
• Provide a surrogate or placeholder for another object to
control access to it.
• The proxy has the same interface as the original object
• Virtual Proxy:
– Creates/accesses expensive objects on demand
– You may wish to delay creating an expensive object until it
is really accessed
– It may be too expensive to keep entire state of the object in
memory at one time
01/16/16 Structural Pattern 24
• Protection Proxy
– Provides different objects different level of access to
original object
• Cache Proxy (Server Proxy)
– Multiple local clients can share results from expensive
operations: remote accesses or long computations
• Firewall Proxy
– Protect local clients from outside world
• Protection Proxy
– Provides different objects different level of access to
original object
• Cache Proxy (Server Proxy)
– Multiple local clients can share results from expensive
operations: remote accesses or long computations
• Firewall Proxy
– Protect local clients from outside world
01/16/16 Structural Pattern 25
ProxyProxy
01/16/16 Structural Pattern 26
Benefits
• Flexible
• Don’t have to foresee all combinations
• Little objects
Possible problems
• Performance
• Decorators are not necessarily always cummutative
(surgeon and Anastasiolic)
01/16/16 Structural Pattern 27
Thank You
01/16/16 Structural Pattern 28
Dr. Himanshu Hora
SRMS College of Engineering & Technology
Bareilly (UP) INDIA
Dr. Himanshu Hora
SRMS College of Engineering & Technology
Bareilly (UP) INDIA

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Design Patterns Presentation - Chetan Gole
Design Patterns Presentation -  Chetan GoleDesign Patterns Presentation -  Chetan Gole
Design Patterns Presentation - Chetan Gole
 
Let us understand design pattern
Let us understand design patternLet us understand design pattern
Let us understand design pattern
 
Design patterns tutorials
Design patterns tutorialsDesign patterns tutorials
Design patterns tutorials
 
Design Patterns - General Introduction
Design Patterns - General IntroductionDesign Patterns - General Introduction
Design Patterns - General Introduction
 
Gof design patterns
Gof design patternsGof design patterns
Gof design patterns
 
Design Pattern - Factory Method Pattern
Design Pattern - Factory Method PatternDesign Pattern - Factory Method Pattern
Design Pattern - Factory Method Pattern
 
Gof design pattern
Gof design patternGof design pattern
Gof design pattern
 
Software design
Software designSoftware design
Software design
 
Design Pattern For C# Part 1
Design Pattern For C# Part 1Design Pattern For C# Part 1
Design Pattern For C# Part 1
 
Design Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory PatternDesign Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory Pattern
 
Builder pattern
Builder patternBuilder pattern
Builder pattern
 
Introduction to Design Pattern
Introduction to Design  PatternIntroduction to Design  Pattern
Introduction to Design Pattern
 
Proxy Design Pattern
Proxy Design PatternProxy Design Pattern
Proxy Design Pattern
 
Domain model
Domain modelDomain model
Domain model
 
Creational pattern
Creational patternCreational pattern
Creational pattern
 
Advanced Structural Modeling
Advanced Structural ModelingAdvanced Structural Modeling
Advanced Structural Modeling
 
Input output streams
Input output streamsInput output streams
Input output streams
 
Prototype pattern
Prototype patternPrototype pattern
Prototype pattern
 
classes & objects introduction
classes & objects introductionclasses & objects introduction
classes & objects introduction
 
An Introduction to Software Architecture
An Introduction to Software ArchitectureAn Introduction to Software Architecture
An Introduction to Software Architecture
 

Andere mochten auch

Structural Design pattern - Adapter
Structural Design pattern - AdapterStructural Design pattern - Adapter
Structural Design pattern - Adapter
Manoj Kumar
 
Business analysis in data warehousing
Business analysis in data warehousingBusiness analysis in data warehousing
Business analysis in data warehousing
Himanshu
 
Importance of software architecture
Importance of software architectureImportance of software architecture
Importance of software architecture
Himanshu
 
Software archiecture lecture07
Software archiecture   lecture07Software archiecture   lecture07
Software archiecture lecture07
Luktalja
 
Architecture business cycle
Architecture business cycleArchitecture business cycle
Architecture business cycle
Himanshu
 

Andere mochten auch (18)

Security and Integrity of Data
Security and Integrity of DataSecurity and Integrity of Data
Security and Integrity of Data
 
Design Pattern
Design PatternDesign Pattern
Design Pattern
 
Behavioral pattern By:-Priyanka Pradhan
Behavioral pattern By:-Priyanka PradhanBehavioral pattern By:-Priyanka Pradhan
Behavioral pattern By:-Priyanka Pradhan
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Pattern
 
Structural Design pattern - Adapter
Structural Design pattern - AdapterStructural Design pattern - Adapter
Structural Design pattern - Adapter
 
Reliability and its principals
Reliability and its principalsReliability and its principals
Reliability and its principals
 
CBAM
 CBAM CBAM
CBAM
 
Structural and functional testing
Structural and functional testingStructural and functional testing
Structural and functional testing
 
Architecture Review
Architecture ReviewArchitecture Review
Architecture Review
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Pattern
 
Software reliability tools and common software errors
Software reliability tools and common software errorsSoftware reliability tools and common software errors
Software reliability tools and common software errors
 
Business analysis in data warehousing
Business analysis in data warehousingBusiness analysis in data warehousing
Business analysis in data warehousing
 
Abc
AbcAbc
Abc
 
Importance of software architecture
Importance of software architectureImportance of software architecture
Importance of software architecture
 
Saam
SaamSaam
Saam
 
Software archiecture lecture07
Software archiecture   lecture07Software archiecture   lecture07
Software archiecture lecture07
 
Architecture business cycle
Architecture business cycleArchitecture business cycle
Architecture business cycle
 
ATAM
ATAMATAM
ATAM
 

Ähnlich wie Structural patterns

Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)
stanbridge
 

Ähnlich wie Structural patterns (20)

Design pattern and their application
Design pattern and their applicationDesign pattern and their application
Design pattern and their application
 
Chapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptChapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.ppt
 
Chapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptChapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.ppt
 
Design patterns Structural
Design patterns StructuralDesign patterns Structural
Design patterns Structural
 
note2_DesignPatterns (1).pptx
note2_DesignPatterns (1).pptxnote2_DesignPatterns (1).pptx
note2_DesignPatterns (1).pptx
 
Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)
 
10-DesignPatterns.ppt
10-DesignPatterns.ppt10-DesignPatterns.ppt
10-DesignPatterns.ppt
 
UNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptxUNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptx
 
Decorator Pattern
Decorator PatternDecorator Pattern
Decorator Pattern
 
Creational Design Patterns.pptx
Creational Design Patterns.pptxCreational Design Patterns.pptx
Creational Design Patterns.pptx
 
Design_Patterns_Dr.CM.ppt
Design_Patterns_Dr.CM.pptDesign_Patterns_Dr.CM.ppt
Design_Patterns_Dr.CM.ppt
 
Related Worksheets
Related WorksheetsRelated Worksheets
Related Worksheets
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
 
Online TechTalk  "Patterns in Embedded SW Design"
Online TechTalk  "Patterns in Embedded SW Design"Online TechTalk  "Patterns in Embedded SW Design"
Online TechTalk  "Patterns in Embedded SW Design"
 
Design Pattern lecture 2
Design Pattern lecture 2Design Pattern lecture 2
Design Pattern lecture 2
 
Design pattern
Design patternDesign pattern
Design pattern
 
Solid Principles Of Design (Design Series 01)
Solid Principles Of Design (Design Series 01)Solid Principles Of Design (Design Series 01)
Solid Principles Of Design (Design Series 01)
 
Introduction to Software - Coder Forge - John Mulhall
Introduction to Software - Coder Forge - John MulhallIntroduction to Software - Coder Forge - John Mulhall
Introduction to Software - Coder Forge - John Mulhall
 
Design patterns
Design patternsDesign patterns
Design patterns
 
designpatterns-.pdf
designpatterns-.pdfdesignpatterns-.pdf
designpatterns-.pdf
 

Mehr von Himanshu

Cost Benefit Analysis Method
Cost Benefit Analysis MethodCost Benefit Analysis Method
Cost Benefit Analysis Method
Himanshu
 

Mehr von Himanshu (20)

Software product line
Software product lineSoftware product line
Software product line
 
Shared information systems
Shared information systemsShared information systems
Shared information systems
 
Saam
SaamSaam
Saam
 
White box black box & gray box testing
White box black box & gray box testingWhite box black box & gray box testing
White box black box & gray box testing
 
Pareto analysis
Pareto analysisPareto analysis
Pareto analysis
 
Load runner & win runner
Load runner & win runnerLoad runner & win runner
Load runner & win runner
 
Crud and jad
Crud and jadCrud and jad
Crud and jad
 
Junit and cactus
Junit and cactusJunit and cactus
Junit and cactus
 
Risk based testing and random testing
Risk based testing and random testingRisk based testing and random testing
Risk based testing and random testing
 
Testing a data warehouses
Testing a data warehousesTesting a data warehouses
Testing a data warehouses
 
Software testing tools and its taxonomy
Software testing tools and its taxonomySoftware testing tools and its taxonomy
Software testing tools and its taxonomy
 
Software reliability engineering process
Software reliability engineering processSoftware reliability engineering process
Software reliability engineering process
 
Software reliability growth model
Software reliability growth modelSoftware reliability growth model
Software reliability growth model
 
Regression and performance testing
Regression and performance testingRegression and performance testing
Regression and performance testing
 
Eleven step of software testing process
Eleven step of software testing processEleven step of software testing process
Eleven step of software testing process
 
Off the-shelf components (cots)
Off the-shelf components (cots)Off the-shelf components (cots)
Off the-shelf components (cots)
 
Building a software testing environment
Building a software testing environmentBuilding a software testing environment
Building a software testing environment
 
Reconstructing Software Architecture
Reconstructing Software ArchitectureReconstructing Software Architecture
Reconstructing Software Architecture
 
Design pattern & categories
Design pattern & categoriesDesign pattern & categories
Design pattern & categories
 
Cost Benefit Analysis Method
Cost Benefit Analysis MethodCost Benefit Analysis Method
Cost Benefit Analysis Method
 

Kürzlich hochgeladen

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Kürzlich hochgeladen (20)

Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 

Structural patterns

  • 1. Structural PatternStructural Pattern Dr. Himanshu Hora SRMS College of Engineering & Technology Bareilly (UP) INDIA Dr. Himanshu Hora SRMS College of Engineering & Technology Bareilly (UP) INDIA 01/16/16 Structural Pattern 1
  • 2. ContentContent • History of Design Pattern • Definitions of Design Pattern • Types of Pattern • Adapter • Bridge • Composite • Decorator • Facade • Flyweight • Proxy • Benefits and Possible problems • History of Design Pattern • Definitions of Design Pattern • Types of Pattern • Adapter • Bridge • Composite • Decorator • Facade • Flyweight • Proxy • Benefits and Possible problems 01/16/16 Structural Pattern 2
  • 3. History of Design PatternHistory of Design Pattern • In 1994, Design Patterns: Elements of Reusable Object- Oriented Software by Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides explained the usefulness of patterns and resulted in the widespread popularity of design patterns. • These four authors together are referred to as the Gang of Four (GoF). • In 1994, Design Patterns: Elements of Reusable Object- Oriented Software by Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides explained the usefulness of patterns and resulted in the widespread popularity of design patterns. • These four authors together are referred to as the Gang of Four (GoF). 01/16/16 Structural Pattern 3
  • 4. Definitions of Design PatternDefinitions of Design Pattern • Design patterns are recurring solutions to software design problems you find again and again in real-world application development OR • Design patterns represent solutions to problems that arise when developing software within a particular context OR • Design patterns are standard solutions to common problems in software design • Design patterns are recurring solutions to software design problems you find again and again in real-world application development OR • Design patterns represent solutions to problems that arise when developing software within a particular context OR • Design patterns are standard solutions to common problems in software design 01/16/16 Structural Pattern 4
  • 5. Types of PatternTypes of Pattern There are 3 types of pattern • Creational: address problems of creating an object in a flexible way. Separate creation, from operation/use. • Structural: address problems of using O-O constructs like inheritance to organize classes and objects • Behavioral: address problems of assigning responsibilities to classes. Suggest both static relationships and patterns of communication (use cases) There are 3 types of pattern • Creational: address problems of creating an object in a flexible way. Separate creation, from operation/use. • Structural: address problems of using O-O constructs like inheritance to organize classes and objects • Behavioral: address problems of assigning responsibilities to classes. Suggest both static relationships and patterns of communication (use cases) 01/16/16 Structural Pattern 5
  • 6. Types of PatternTypes of Pattern Creational Patterns (concerned with abstracting the object-instantiation process) • Factory Method Abstract Factory Singleton • Builder Prototype Structural Patterns (concerned with how objects/classes can be combined to form larger structures) • Adapter Bridge Composite • Decorator Facade Flyweight • Proxy Behavioral Patterns (concerned with communication between objects) • Command Interpreter Iterator • Mediator Observer State • Strategy Chain of Responsibility Visitor • Template Method Creational Patterns (concerned with abstracting the object-instantiation process) • Factory Method Abstract Factory Singleton • Builder Prototype Structural Patterns (concerned with how objects/classes can be combined to form larger structures) • Adapter Bridge Composite • Decorator Facade Flyweight • Proxy Behavioral Patterns (concerned with communication between objects) • Command Interpreter Iterator • Mediator Observer State • Strategy Chain of Responsibility Visitor • Template Method 01/16/16 Structural Pattern 6
  • 7. AdapterAdapter • Convert the interface of a class into another interface clients expect • Adapter lets classes work together that couldn't otherwise because of incompatible interfaces • Use the Adapter pattern when: – you want to use an existing class and its interface does not match the one you need – you need to use several existing subclasses, but it's impractical to adapt their interface by subclassing everyone. An object adapter can adapt the interface of its parent class • Convert the interface of a class into another interface clients expect • Adapter lets classes work together that couldn't otherwise because of incompatible interfaces • Use the Adapter pattern when: – you want to use an existing class and its interface does not match the one you need – you need to use several existing subclasses, but it's impractical to adapt their interface by subclassing everyone. An object adapter can adapt the interface of its parent class 01/16/16 Structural Pattern 7
  • 9. BridgeBridge • Decouple an abstraction from its implementation so that the two can vary independently • Use the Bridge pattern when: – you want run-time binding of the implementation – you want to share an implementation among multiple objects • Decouple an abstraction from its implementation so that the two can vary independently • Use the Bridge pattern when: – you want run-time binding of the implementation – you want to share an implementation among multiple objects 01/16/16 Structural Pattern 9
  • 11. CompositeComposite • Compose objects into tree structures to represent whole-part hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly • Use this pattern whenever you have "composites that contain components, each of which could be a composite". • Compose objects into tree structures to represent whole-part hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly • Use this pattern whenever you have "composites that contain components, each of which could be a composite". 01/16/16 Structural Pattern 11
  • 13. DecoratorDecorator • Attach additional responsibilities to an object dynamically • Decorators provide a flexible alternative to subclassing for extending functionality • Attach additional responsibilities to an object dynamically • Decorators provide a flexible alternative to subclassing for extending functionality 01/16/16 Structural Pattern 13
  • 14. ProblemsProblems • Several classes with a similar operation (method), but different behavior. • We want to use many combinations of these behaviors • Several classes with a similar operation (method), but different behavior. • We want to use many combinations of these behaviors 01/16/16 Structural Pattern 14
  • 15. Example - Automated HospitalExample - Automated Hospital • People come to the reception with problems • They describe their problems • A special doctoRobot is created that is specialized to treat their special situations. • People come to the reception with problems • They describe their problems • A special doctoRobot is created that is specialized to treat their special situations. 01/16/16 Structural Pattern 15
  • 16. Automated Hospital - Solution 1Automated Hospital - Solution 1 DoctoRobot Cure (p : Patient) DentistRobot Cure (p : Patient) DermaRobot Cure (p : Patient) PsychoRobot Cure (p : Patient) DentistDermaRobot DentistPsychoRobot DermaPsychoRobot 01/16/16 Structural Pattern 16
  • 17. Problems with solution-1Problems with solution-1 • Sometimes we don’t have multiple inheritance. • Even if we have, if is problematic, and bad design. • Sometimes we don’t have multiple inheritance. • Even if we have, if is problematic, and bad design. 01/16/16 Structural Pattern 17
  • 18. A Better idea: Use DecoratorA Better idea: Use Decorator ConcreteComponent Operation( ) ConcreteDecoratorA addedState Operation( ) ConcreteDecoratorB Operation( ) Decorator Operation( ) Component Operation( ) component 01/16/16 Structural Pattern 18
  • 19. Decorator in our caseDecorator in our case DentistRobot Cure (p : Patient) DermaRobot Cure (p : Patient) PhsychoRobot Cure (p : Patient) DoctorRobotDecorator innerDoctor Cure (p : Patient) DoctoRobot Cure (p : Patient) component 01/16/16 Structural Pattern 19
  • 20. FacadeFacade • Provide a unified interface to a set of interfaces in a subsystem • Facade defines a higher-level interface that makes the subsystem easier to use • Create a class that is the interface to the subsystem • Clients interface with the Facade class to deal with the subsystem • It hides the implementation of the subsystem from clients • It promotes weak coupling between the subsystems and its clients • It does not prevent clients from using subsystems class, should it? • Provide a unified interface to a set of interfaces in a subsystem • Facade defines a higher-level interface that makes the subsystem easier to use • Create a class that is the interface to the subsystem • Clients interface with the Facade class to deal with the subsystem • It hides the implementation of the subsystem from clients • It promotes weak coupling between the subsystems and its clients • It does not prevent clients from using subsystems class, should it? 01/16/16 Structural Pattern 20
  • 22. FlyweightFlyweight • Use sharing to support large numbers of fine-grained objects efficiently • The pattern can be used when: – The program uses a large number of objects and – The program does not use object identity (==) • Use sharing to support large numbers of fine-grained objects efficiently • The pattern can be used when: – The program uses a large number of objects and – The program does not use object identity (==) 01/16/16 Structural Pattern 22
  • 24. ProxyProxy • Provide a surrogate or placeholder for another object to control access to it. • The proxy has the same interface as the original object • Virtual Proxy: – Creates/accesses expensive objects on demand – You may wish to delay creating an expensive object until it is really accessed – It may be too expensive to keep entire state of the object in memory at one time • Provide a surrogate or placeholder for another object to control access to it. • The proxy has the same interface as the original object • Virtual Proxy: – Creates/accesses expensive objects on demand – You may wish to delay creating an expensive object until it is really accessed – It may be too expensive to keep entire state of the object in memory at one time 01/16/16 Structural Pattern 24
  • 25. • Protection Proxy – Provides different objects different level of access to original object • Cache Proxy (Server Proxy) – Multiple local clients can share results from expensive operations: remote accesses or long computations • Firewall Proxy – Protect local clients from outside world • Protection Proxy – Provides different objects different level of access to original object • Cache Proxy (Server Proxy) – Multiple local clients can share results from expensive operations: remote accesses or long computations • Firewall Proxy – Protect local clients from outside world 01/16/16 Structural Pattern 25
  • 27. Benefits • Flexible • Don’t have to foresee all combinations • Little objects Possible problems • Performance • Decorators are not necessarily always cummutative (surgeon and Anastasiolic) 01/16/16 Structural Pattern 27
  • 28. Thank You 01/16/16 Structural Pattern 28 Dr. Himanshu Hora SRMS College of Engineering & Technology Bareilly (UP) INDIA Dr. Himanshu Hora SRMS College of Engineering & Technology Bareilly (UP) INDIA