SlideShare a Scribd company logo
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

More Related Content

PDF
Gof design pattern
PPT
Introduction to design patterns
PPTX
Gof design patterns
PPTX
SOLID - Principles of Object Oriented Design
PPT
Software Design Patterns
PPTX
Let us understand design pattern
PPTX
Creational pattern
PDF
Introduction to Design Pattern
Gof design pattern
Introduction to design patterns
Gof design patterns
SOLID - Principles of Object Oriented Design
Software Design Patterns
Let us understand design pattern
Creational pattern
Introduction to Design Pattern

What's hot (20)

PPTX
PATTERNS04 - Structural Design Patterns
PPTX
Waterfall model
PPTX
Waterfall model ppt final
PPT
Object Oriented Design
PPT
MYSQL - PHP Database Connectivity
PPTX
Design pattern-presentation
PPTX
Sequence diagram
PPT
Unit 1( modelling concepts & class modeling)
PPT
Unit 4 designing classes
PPT
08 state diagram and activity diagram
PDF
The Object Model
PPTX
Types and roles
PPTX
Object Modeling Techniques
PPTX
Java I/O and Object Serialization
PDF
Command line-arguments-in-java-tutorial
PPT
Object oriented analysis
PPT
PPT
Requirements engineering process in software engineering
PPT
Design patterns ppt
PATTERNS04 - Structural Design Patterns
Waterfall model
Waterfall model ppt final
Object Oriented Design
MYSQL - PHP Database Connectivity
Design pattern-presentation
Sequence diagram
Unit 1( modelling concepts & class modeling)
Unit 4 designing classes
08 state diagram and activity diagram
The Object Model
Types and roles
Object Modeling Techniques
Java I/O and Object Serialization
Command line-arguments-in-java-tutorial
Object oriented analysis
Requirements engineering process in software engineering
Design patterns ppt
Ad

Viewers also liked (18)

PPTX
Security and Integrity of Data
PPTX
Design Pattern
PPTX
Behavioral pattern By:-Priyanka Pradhan
PPTX
Adapter Design Pattern
PPTX
Structural Design pattern - Adapter
PPTX
Reliability and its principals
PPT
PPTX
Structural and functional testing
PPTX
Architecture Review
ZIP
Adapter Design Pattern
PPTX
Software reliability tools and common software errors
PPTX
Business analysis in data warehousing
PPTX
PPTX
Importance of software architecture
PPTX
Saam
PDF
Software archiecture lecture07
PPTX
Architecture business cycle
PPT
ATAM
Security and Integrity of Data
Design Pattern
Behavioral pattern By:-Priyanka Pradhan
Adapter Design Pattern
Structural Design pattern - Adapter
Reliability and its principals
Structural and functional testing
Architecture Review
Adapter Design Pattern
Software reliability tools and common software errors
Business analysis in data warehousing
Importance of software architecture
Saam
Software archiecture lecture07
Architecture business cycle
ATAM
Ad

Similar to Structural patterns (20)

PDF
Module 4: UML In Action - Design Patterns
PPT
M04_DesignPatterns software engineering.ppt
PPTX
PPT
Software Architecture and Project Management module III : PATTERN OF ENTERPRISE
PDF
Design Pattern in Software Engineering
PPTX
ap assignmnet presentation.pptx
PPTX
C# Design Patterns | Design Pattern Tutorial For Beginners | C# Programming T...
PDF
designpatterns-.pdf
PPTX
Design patterns
PDF
Design Patterns Java programming language.pdf
PPT
M04 Design Patterns
PPTX
Design pattern and their application
PDF
software engineering Design Patterns.pdf
PPTX
GoF Design patterns I: Introduction + Structural Patterns
PDF
Software Engineering - chp4- design patterns
PPTX
Object Oriented Design Patterns
PPT
Software Design Patterns
PPT
Design Patterns
DOCX
Design patterns
PPT
My design patterns
Module 4: UML In Action - Design Patterns
M04_DesignPatterns software engineering.ppt
Software Architecture and Project Management module III : PATTERN OF ENTERPRISE
Design Pattern in Software Engineering
ap assignmnet presentation.pptx
C# Design Patterns | Design Pattern Tutorial For Beginners | C# Programming T...
designpatterns-.pdf
Design patterns
Design Patterns Java programming language.pdf
M04 Design Patterns
Design pattern and their application
software engineering Design Patterns.pdf
GoF Design patterns I: Introduction + Structural Patterns
Software Engineering - chp4- design patterns
Object Oriented Design Patterns
Software Design Patterns
Design Patterns
Design patterns
My design patterns

More from Himanshu (20)

PPTX
Software product line
PPT
Shared information systems
PPTX
Saam
PPTX
White box black box & gray box testing
PPTX
Pareto analysis
PPTX
Load runner & win runner
PPTX
Crud and jad
PPTX
Junit and cactus
PPTX
Risk based testing and random testing
PPTX
Testing a data warehouses
PPTX
Software testing tools and its taxonomy
PPTX
Software reliability engineering process
PPTX
Software reliability growth model
PPTX
Regression and performance testing
PPTX
Eleven step of software testing process
PPTX
Off the-shelf components (cots)
PPTX
Building a software testing environment
PPTX
Reconstructing Software Architecture
PPT
Design pattern & categories
PPTX
Cost Benefit Analysis Method
Software product line
Shared information systems
Saam
White box black box & gray box testing
Pareto analysis
Load runner & win runner
Crud and jad
Junit and cactus
Risk based testing and random testing
Testing a data warehouses
Software testing tools and its taxonomy
Software reliability engineering process
Software reliability growth model
Regression and performance testing
Eleven step of software testing process
Off the-shelf components (cots)
Building a software testing environment
Reconstructing Software Architecture
Design pattern & categories
Cost Benefit Analysis Method

Recently uploaded (20)

DOCX
UPPER GASTRO INTESTINAL DISORDER.docx
PDF
The Final Stretch: How to Release a Game and Not Die in the Process.
PPTX
Open Quiz Monsoon Mind Game Prelims.pptx
PPTX
Revamp in MTO Odoo 18 Inventory - Odoo Slides
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Insiders guide to clinical Medicine.pdf
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
UNDER FIVE CLINICS OR WELL BABY CLINICS.pptx
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PDF
Business Ethics Teaching Materials for college
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PPTX
How to Manage Starshipit in Odoo 18 - Odoo Slides
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PPTX
COMPUTERS AS DATA ANALYSIS IN PRECLINICAL DEVELOPMENT.pptx
PDF
Open folder Downloads.pdf yes yes ges yes
PPTX
Introduction and Scope of Bichemistry.pptx
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
PPTX
Onica Farming 24rsclub profitable farm business
UPPER GASTRO INTESTINAL DISORDER.docx
The Final Stretch: How to Release a Game and Not Die in the Process.
Open Quiz Monsoon Mind Game Prelims.pptx
Revamp in MTO Odoo 18 Inventory - Odoo Slides
human mycosis Human fungal infections are called human mycosis..pptx
Insiders guide to clinical Medicine.pdf
O5-L3 Freight Transport Ops (International) V1.pdf
UNDER FIVE CLINICS OR WELL BABY CLINICS.pptx
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
Business Ethics Teaching Materials for college
STATICS OF THE RIGID BODIES Hibbelers.pdf
Renaissance Architecture: A Journey from Faith to Humanism
How to Manage Starshipit in Odoo 18 - Odoo Slides
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
COMPUTERS AS DATA ANALYSIS IN PRECLINICAL DEVELOPMENT.pptx
Open folder Downloads.pdf yes yes ges yes
Introduction and Scope of Bichemistry.pptx
102 student loan defaulters named and shamed – Is someone you know on the list?
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
Onica Farming 24rsclub profitable farm business

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