SlideShare a Scribd company logo
1 of 15
Facade Pattern
(A Structural Pattern)
Facade
ï‚—Intent
 ï‚—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.
Motivation
ï‚—Structuring a system into subsystems helps reduce complexity.


ï‚—A common design goal is to minimize the communication and dependencies between subsystems.


ï‚—One way to achieve this goal is to introduce a facade object that provides a single, simplified interface to the more general facilities of a subsystem.

ï‚— Consider for example a programming environment that gives applications access to its
      compiler subsystem.

ï‚— This subsystem contains classes such as Scanner, Parser, ProgramNode,
      BytecodeStream, and ProgramNodeBuilder that implement the compiler.

ï‚— Most clients of a compiler generally don't care about details like parsing and code
      generation; they merely want to compile some code. For them, the powerful but low-
Motivation
ï‚— To provide a higher-level interface that can shield clients from these classes, the compiler subsystem also
   includes a Compiler class. This class defines a unified interface to the compiler's functionality. The Compiler
   class acts as a facade: It offers clients a single, simple interface to the compiler subsystem. It glues together the
   classes that implement compiler functionality without hiding them completely. The compiler facade makes life
   easier for most programmers without hiding the lower-level functionality from the few that need it.
Applicability
ï‚— Use the Facade pattern when


    ï‚— you want to provide a simple interface to a complex subsystem. Subsystems often get
      more complex as they evolve. Most patterns, when applied, result in more and smaller
      classes. This makes the subsystem more reusable and easier to customize, but it also
      becomes harder to use for clients that don't need to customize it. A facade can provide a
      simple default view of the subsystem that is good enough for most clients. Only clients
      needing more customizability will need to look beyond the facade.

    ï‚— there are many dependencies between clients and the implementation classes of an
      abstraction. Introduce a facade to decouple the subsystem from clients and other
      subsystems, thereby promoting subsystem independence and portability.

    ï‚— you want to layer your subsystems. Use a facade to define an entry point to each
      subsystem level. If subsystems are dependent, then you can simplify the dependencies
      between them by making them communicate with each other solely through their
      facades.
Structure
Participants
ï‚—Facade (Compiler)
  ï‚—knows which subsystem classes are responsible for a
   request.
  ï‚—delegates client requests to appropriate subsystem
   objects.
ï‚—subsystem classes (Scanner, Parser, ProgramNode,
 etc.)
  ï‚—implement subsystem functionality.
  ï‚—handle work assigned by the Facade object.
  ï‚—have no knowledge of the facade; that is, they keep no
    references to it.
Collaborations
ï‚—Clients communicate with the subsystem by sending
 requests to Facade, which forwards them to the
 appropriate subsystem object(s). Although the
 subsystem objects perform the actual work, the
 facade may have to do work of its own to translate its
 interface to subsystem interfaces.

ï‚—Clients that use the facade don't have to access its
 subsystem objects directly.
Consequences
ï‚— The Facade pattern offers the following benefits:

   ï‚— It shields clients from subsystem components, thereby reducing the number of
      objects that clients deal with and making the subsystem easier to use.

   ï‚— It promotes weak coupling between the subsystem and its clients. Often the
      components in a subsystem are strongly coupled. Weak coupling lets you vary
      the components of the subsystem without affecting its clients. Facades help
      layer a system and the dependencies between objects. They can eliminate
      complex or circular dependencies. This can be an important consequence
      when the client and the subsystem are implemented independently. Reducing
      compilation dependencies is vital in large software systems. You want to save
      time by minimizing recompilation when subsystem classes change. Reducing
      compilation dependencies with facades can limit the recompilation needed for
      a small change in an important subsystem. A facade can also simplify porting
      systems to other platforms, because it's less likely that building one subsystem
      requires building all others.

   ï‚— It doesn't prevent applications from using subsystem classes if they need to.
      Thus you can choose between ease of use and generality.
Implementation
ï‚— Reducing client-subsystem coupling. The coupling between clients and the
  subsystem can be reduced even further by making Facade an abstract class
  with concrete subclasses for different implementations of a subsystem. Then
  clients can communicate with the subsystem through the interface of the
  abstract Facade class. This abstract coupling keeps clients from knowing
  which implementation of a subsystem is used. An alternative to subclassing is
  to configure a Facade object with different subsystem objects. To customize
  the facade, simply replace one or more of its subsystem objects.

ï‚— Public versus private subsystem classes. A subsystem is analogous to a class in
  that both have interfaces, and both encapsulate something—a class
  encapsulates state and operations, while a subsystem encapsulates classes.
  And just as it's useful to think of the public and private interface of a class, we
  can think of the public and private interface of a subsystem. The public
  interface to a subsystem consists of classes that all clients can access; the
  private interface is just for subsystem extenders. The Facade class is part of
  the public interface, of course, but it's not the only part. Other subsystem
  classes are usually public as well. For example, the classes Parser and Scanner
  in the compiler subsystem are part of the public interface.
Sample Code
Sample Code
Sample Code
Sample Code
Assignment
ï‚— An operating system is a vast system. It is for obvious reasons divided
  into several subsystems such as memory manager, process manager,
  storage manager, I/O manager, etc.

 For simplicity, let’s assume an OS has the following tasks only: a)
  Boot, b) Shutdown, c) Run a process, d) Kill a process, e) Take input
  from devices and provide output to devices while running a process.

ï‚— Design a system with a root facade, several subsystems with their
  own facades, and communication/collaboration among them . Please
  base your design relevant to the information provided in the second
  paragraph.

More Related Content

What's hot

Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Patternmelbournepatterns
 
Prototype pattern
Prototype patternPrototype pattern
Prototype patternShakil Ahmed
 
Composite pattern
Composite patternComposite pattern
Composite patternShakil Ahmed
 
Bridge pattern
Bridge patternBridge pattern
Bridge patternShakil Ahmed
 
Proxy pattern
Proxy patternProxy pattern
Proxy patternShakil Ahmed
 
The Singleton Pattern Presentation
The Singleton Pattern PresentationThe Singleton Pattern Presentation
The Singleton Pattern PresentationJAINIK PATEL
 
Design Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory PatternDesign Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory PatternMudasir Qazi
 
Flyweight pattern
Flyweight patternFlyweight pattern
Flyweight patternShakil Ahmed
 
Prototype_pattern
Prototype_patternPrototype_pattern
Prototype_patternIryney Baran
 
Introduction to design patterns
Introduction to design patternsIntroduction to design patterns
Introduction to design patternsAmit Kabra
 
Prototype design patterns
Prototype design patternsPrototype design patterns
Prototype design patternsThaichor Seng
 
Design Patterns - General Introduction
Design Patterns - General IntroductionDesign Patterns - General Introduction
Design Patterns - General IntroductionAsma CHERIF
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design PatternAdeel Riaz
 
Design pattern-presentation
Design pattern-presentationDesign pattern-presentation
Design pattern-presentationRana Muhammad Asif
 
PATTERNS02 - Creational Design Patterns
PATTERNS02 - Creational Design PatternsPATTERNS02 - Creational Design Patterns
PATTERNS02 - Creational Design PatternsMichael Heron
 
PATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design PatternsPATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design PatternsMichael Heron
 
Design Patterns - 01 Introduction and Decorator Pattern
Design Patterns - 01 Introduction and Decorator PatternDesign Patterns - 01 Introduction and Decorator Pattern
Design Patterns - 01 Introduction and Decorator Patterneprafulla
 
Design Pattern - Factory Method Pattern
Design Pattern - Factory Method PatternDesign Pattern - Factory Method Pattern
Design Pattern - Factory Method PatternMudasir Qazi
 
Design Pattern - Singleton Pattern
Design Pattern - Singleton PatternDesign Pattern - Singleton Pattern
Design Pattern - Singleton PatternMudasir Qazi
 

What's hot (20)

Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Pattern
 
Prototype pattern
Prototype patternPrototype pattern
Prototype pattern
 
Composite pattern
Composite patternComposite pattern
Composite pattern
 
Bridge pattern
Bridge patternBridge pattern
Bridge pattern
 
Proxy pattern
Proxy patternProxy pattern
Proxy pattern
 
The Singleton Pattern Presentation
The Singleton Pattern PresentationThe Singleton Pattern Presentation
The Singleton Pattern Presentation
 
Design Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory PatternDesign Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory Pattern
 
Flyweight pattern
Flyweight patternFlyweight pattern
Flyweight pattern
 
Prototype_pattern
Prototype_patternPrototype_pattern
Prototype_pattern
 
Introduction to design patterns
Introduction to design patternsIntroduction to design patterns
Introduction to design patterns
 
Prototype design patterns
Prototype design patternsPrototype design patterns
Prototype design patterns
 
Design Patterns - General Introduction
Design Patterns - General IntroductionDesign Patterns - General Introduction
Design Patterns - General Introduction
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Pattern
 
Design pattern-presentation
Design pattern-presentationDesign pattern-presentation
Design pattern-presentation
 
Proxy Design Pattern
Proxy Design PatternProxy Design Pattern
Proxy Design Pattern
 
PATTERNS02 - Creational Design Patterns
PATTERNS02 - Creational Design PatternsPATTERNS02 - Creational Design Patterns
PATTERNS02 - Creational Design Patterns
 
PATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design PatternsPATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design Patterns
 
Design Patterns - 01 Introduction and Decorator Pattern
Design Patterns - 01 Introduction and Decorator PatternDesign Patterns - 01 Introduction and Decorator Pattern
Design Patterns - 01 Introduction and Decorator Pattern
 
Design Pattern - Factory Method Pattern
Design Pattern - Factory Method PatternDesign Pattern - Factory Method Pattern
Design Pattern - Factory Method Pattern
 
Design Pattern - Singleton Pattern
Design Pattern - Singleton PatternDesign Pattern - Singleton Pattern
Design Pattern - Singleton Pattern
 

Similar to Facade pattern

L12-DP(SP-Facade).pptx
L12-DP(SP-Facade).pptxL12-DP(SP-Facade).pptx
L12-DP(SP-Facade).pptxasimaBashir3
 
Facadepattern
FacadepatternFacadepattern
FacadepatternJAINIK PATEL
 
Design patterns
Design patternsDesign patterns
Design patternsBinu Bhasuran
 
Nina Grantcharova - Approach to Separation of Concerns via Design Patterns
Nina Grantcharova - Approach to Separation of Concerns via Design PatternsNina Grantcharova - Approach to Separation of Concerns via Design Patterns
Nina Grantcharova - Approach to Separation of Concerns via Design Patternsiasaglobal
 
Ports adapters architecture (hexagonal architecture)
Ports adapters architecture (hexagonal architecture)Ports adapters architecture (hexagonal architecture)
Ports adapters architecture (hexagonal architecture)Farhad Taran
 
Polymorphism and interface in vb.net
Polymorphism and interface in vb.netPolymorphism and interface in vb.net
Polymorphism and interface in vb.netKarthigaGunasekaran1
 
Layered architecture style
Layered architecture styleLayered architecture style
Layered architecture styleBegench Suhanov
 
Software Architecture and Project Management module III : PATTERN OF ENTERPRISE
Software Architecture and Project Management module III : PATTERN OF ENTERPRISESoftware Architecture and Project Management module III : PATTERN OF ENTERPRISE
Software Architecture and Project Management module III : PATTERN OF ENTERPRISEsreeja_rajesh
 
Systems Archticture
Systems ArchtictureSystems Archticture
Systems ArchtictureSamer Abdalla
 
Distributed architecture (SAD)
Distributed architecture (SAD)Distributed architecture (SAD)
Distributed architecture (SAD)Khubaib Ahmad Kunjahi
 
An approach of software engineering through middleware
An approach of software engineering through middlewareAn approach of software engineering through middleware
An approach of software engineering through middlewareIAEME Publication
 
Introduction to Java Enterprise Edition
Introduction to Java Enterprise EditionIntroduction to Java Enterprise Edition
Introduction to Java Enterprise EditionAbdalla Mahmoud
 
Software architectural patterns - A Quick Understanding Guide
Software architectural patterns - A Quick Understanding GuideSoftware architectural patterns - A Quick Understanding Guide
Software architectural patterns - A Quick Understanding GuideMohammed Fazuluddin
 
Pattern oriented architecture for web based architecture
Pattern oriented architecture for web based architecturePattern oriented architecture for web based architecture
Pattern oriented architecture for web based architectureshuchi tripathi
 

Similar to Facade pattern (20)

L12-DP(SP-Facade).pptx
L12-DP(SP-Facade).pptxL12-DP(SP-Facade).pptx
L12-DP(SP-Facade).pptx
 
Facadepattern
FacadepatternFacadepattern
Facadepattern
 
Facade Design Pattern
Facade Design PatternFacade Design Pattern
Facade Design Pattern
 
Facade design pattern
Facade design patternFacade design pattern
Facade design pattern
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Nina Grantcharova - Approach to Separation of Concerns via Design Patterns
Nina Grantcharova - Approach to Separation of Concerns via Design PatternsNina Grantcharova - Approach to Separation of Concerns via Design Patterns
Nina Grantcharova - Approach to Separation of Concerns via Design Patterns
 
Ports adapters architecture (hexagonal architecture)
Ports adapters architecture (hexagonal architecture)Ports adapters architecture (hexagonal architecture)
Ports adapters architecture (hexagonal architecture)
 
Polymorphism and interface in vb.net
Polymorphism and interface in vb.netPolymorphism and interface in vb.net
Polymorphism and interface in vb.net
 
Layered architecture style
Layered architecture styleLayered architecture style
Layered architecture style
 
Sda 9
Sda   9Sda   9
Sda 9
 
Software Architecture and Project Management module III : PATTERN OF ENTERPRISE
Software Architecture and Project Management module III : PATTERN OF ENTERPRISESoftware Architecture and Project Management module III : PATTERN OF ENTERPRISE
Software Architecture and Project Management module III : PATTERN OF ENTERPRISE
 
TermPaper
TermPaperTermPaper
TermPaper
 
Lec 4.ppt
Lec 4.pptLec 4.ppt
Lec 4.ppt
 
LANSim
LANSimLANSim
LANSim
 
Systems Archticture
Systems ArchtictureSystems Archticture
Systems Archticture
 
Distributed architecture (SAD)
Distributed architecture (SAD)Distributed architecture (SAD)
Distributed architecture (SAD)
 
An approach of software engineering through middleware
An approach of software engineering through middlewareAn approach of software engineering through middleware
An approach of software engineering through middleware
 
Introduction to Java Enterprise Edition
Introduction to Java Enterprise EditionIntroduction to Java Enterprise Edition
Introduction to Java Enterprise Edition
 
Software architectural patterns - A Quick Understanding Guide
Software architectural patterns - A Quick Understanding GuideSoftware architectural patterns - A Quick Understanding Guide
Software architectural patterns - A Quick Understanding Guide
 
Pattern oriented architecture for web based architecture
Pattern oriented architecture for web based architecturePattern oriented architecture for web based architecture
Pattern oriented architecture for web based architecture
 

More from Shakil Ahmed

B-tree & R-tree
B-tree & R-treeB-tree & R-tree
B-tree & R-treeShakil Ahmed
 
Advanced data structure
Advanced data structureAdvanced data structure
Advanced data structureShakil Ahmed
 
Observer pattern
Observer patternObserver pattern
Observer patternShakil Ahmed
 
Mediator pattern
Mediator patternMediator pattern
Mediator patternShakil Ahmed
 
Command pattern
Command patternCommand pattern
Command patternShakil Ahmed
 
Chain of responsibility
Chain of responsibilityChain of responsibility
Chain of responsibilityShakil Ahmed
 
Builder pattern
Builder patternBuilder pattern
Builder patternShakil Ahmed
 
Ios development
Ios developmentIos development
Ios developmentShakil Ahmed
 
Lowest common ancestor
Lowest common ancestorLowest common ancestor
Lowest common ancestorShakil Ahmed
 
Segment tree
Segment treeSegment tree
Segment treeShakil Ahmed
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programmingShakil Ahmed
 
Advanced Search Techniques
Advanced Search TechniquesAdvanced Search Techniques
Advanced Search TechniquesShakil Ahmed
 

More from Shakil Ahmed (17)

Algorithm
AlgorithmAlgorithm
Algorithm
 
B-tree & R-tree
B-tree & R-treeB-tree & R-tree
B-tree & R-tree
 
Advanced data structure
Advanced data structureAdvanced data structure
Advanced data structure
 
Observer pattern
Observer patternObserver pattern
Observer pattern
 
Mediator pattern
Mediator patternMediator pattern
Mediator pattern
 
Command pattern
Command patternCommand pattern
Command pattern
 
Chain of responsibility
Chain of responsibilityChain of responsibility
Chain of responsibility
 
Builder pattern
Builder patternBuilder pattern
Builder pattern
 
iOS 5
iOS 5iOS 5
iOS 5
 
Ios development
Ios developmentIos development
Ios development
 
Graph
GraphGraph
Graph
 
Lowest common ancestor
Lowest common ancestorLowest common ancestor
Lowest common ancestor
 
Segment tree
Segment treeSegment tree
Segment tree
 
Tree & bst
Tree & bstTree & bst
Tree & bst
 
Trie tree
Trie treeTrie tree
Trie tree
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
Advanced Search Techniques
Advanced Search TechniquesAdvanced Search Techniques
Advanced Search Techniques
 

Recently uploaded

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 

Recently uploaded (20)

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 

Facade pattern

  • 2. Facade ï‚—Intent ï‚—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.
  • 3. Motivation ï‚—Structuring a system into subsystems helps reduce complexity. ï‚—A common design goal is to minimize the communication and dependencies between subsystems. ï‚—One way to achieve this goal is to introduce a facade object that provides a single, simplified interface to the more general facilities of a subsystem. ï‚— Consider for example a programming environment that gives applications access to its compiler subsystem. ï‚— This subsystem contains classes such as Scanner, Parser, ProgramNode, BytecodeStream, and ProgramNodeBuilder that implement the compiler. ï‚— Most clients of a compiler generally don't care about details like parsing and code generation; they merely want to compile some code. For them, the powerful but low-
  • 4. Motivation ï‚— To provide a higher-level interface that can shield clients from these classes, the compiler subsystem also includes a Compiler class. This class defines a unified interface to the compiler's functionality. The Compiler class acts as a facade: It offers clients a single, simple interface to the compiler subsystem. It glues together the classes that implement compiler functionality without hiding them completely. The compiler facade makes life easier for most programmers without hiding the lower-level functionality from the few that need it.
  • 5. Applicability ï‚— Use the Facade pattern when ï‚— you want to provide a simple interface to a complex subsystem. Subsystems often get more complex as they evolve. Most patterns, when applied, result in more and smaller classes. This makes the subsystem more reusable and easier to customize, but it also becomes harder to use for clients that don't need to customize it. A facade can provide a simple default view of the subsystem that is good enough for most clients. Only clients needing more customizability will need to look beyond the facade. ï‚— there are many dependencies between clients and the implementation classes of an abstraction. Introduce a facade to decouple the subsystem from clients and other subsystems, thereby promoting subsystem independence and portability. ï‚— you want to layer your subsystems. Use a facade to define an entry point to each subsystem level. If subsystems are dependent, then you can simplify the dependencies between them by making them communicate with each other solely through their facades.
  • 7. Participants ï‚—Facade (Compiler) ï‚—knows which subsystem classes are responsible for a request. ï‚—delegates client requests to appropriate subsystem objects. ï‚—subsystem classes (Scanner, Parser, ProgramNode, etc.) ï‚—implement subsystem functionality. ï‚—handle work assigned by the Facade object. ï‚—have no knowledge of the facade; that is, they keep no references to it.
  • 8. Collaborations ï‚—Clients communicate with the subsystem by sending requests to Facade, which forwards them to the appropriate subsystem object(s). Although the subsystem objects perform the actual work, the facade may have to do work of its own to translate its interface to subsystem interfaces. ï‚—Clients that use the facade don't have to access its subsystem objects directly.
  • 9. Consequences ï‚— The Facade pattern offers the following benefits: ï‚— It shields clients from subsystem components, thereby reducing the number of objects that clients deal with and making the subsystem easier to use. ï‚— It promotes weak coupling between the subsystem and its clients. Often the components in a subsystem are strongly coupled. Weak coupling lets you vary the components of the subsystem without affecting its clients. Facades help layer a system and the dependencies between objects. They can eliminate complex or circular dependencies. This can be an important consequence when the client and the subsystem are implemented independently. Reducing compilation dependencies is vital in large software systems. You want to save time by minimizing recompilation when subsystem classes change. Reducing compilation dependencies with facades can limit the recompilation needed for a small change in an important subsystem. A facade can also simplify porting systems to other platforms, because it's less likely that building one subsystem requires building all others. ï‚— It doesn't prevent applications from using subsystem classes if they need to. Thus you can choose between ease of use and generality.
  • 10. Implementation ï‚— Reducing client-subsystem coupling. The coupling between clients and the subsystem can be reduced even further by making Facade an abstract class with concrete subclasses for different implementations of a subsystem. Then clients can communicate with the subsystem through the interface of the abstract Facade class. This abstract coupling keeps clients from knowing which implementation of a subsystem is used. An alternative to subclassing is to configure a Facade object with different subsystem objects. To customize the facade, simply replace one or more of its subsystem objects. ï‚— Public versus private subsystem classes. A subsystem is analogous to a class in that both have interfaces, and both encapsulate something—a class encapsulates state and operations, while a subsystem encapsulates classes. And just as it's useful to think of the public and private interface of a class, we can think of the public and private interface of a subsystem. The public interface to a subsystem consists of classes that all clients can access; the private interface is just for subsystem extenders. The Facade class is part of the public interface, of course, but it's not the only part. Other subsystem classes are usually public as well. For example, the classes Parser and Scanner in the compiler subsystem are part of the public interface.
  • 15. Assignment ï‚— An operating system is a vast system. It is for obvious reasons divided into several subsystems such as memory manager, process manager, storage manager, I/O manager, etc. ï‚— For simplicity, let’s assume an OS has the following tasks only: a) Boot, b) Shutdown, c) Run a process, d) Kill a process, e) Take input from devices and provide output to devices while running a process. ï‚— Design a system with a root facade, several subsystems with their own facades, and communication/collaboration among them . Please base your design relevant to the information provided in the second paragraph.