SlideShare une entreprise Scribd logo
1  sur  29
Télécharger pour lire hors ligne
Façade
Design
Pattern
Presented by
Masoud Sadrnezhaad
October 28, 2023
Table of contents
When to apply the Façade
pattern in software design?
Classes, Instances, States,
SOLID Principles
Exploring the concept and
purpose of façade pattern.
How clients interact with the
Façade and some codes.
Visual representation of the
pattern's structural diagram
Abstract Factory, Mediator,
Singleton
01
04
02
05
03
06
Object-Oriented Introduction Diagrams
Applicability Sample Code Related Patterns
Object-Oriented
01
Classes, Instances, States, SOLID Principles
Single Responsibility Principle
Open-Closed Principle
Liskov Substitution Principle
Interface Segregation Principle
Dependency Inversion Principle
Introduction
02
Exploring the concept and purpose of
façade pattern.
Design Patterns
Design Patterns
● Best practices for software development
recurring design problems
● Includes problem descriptions, solutions, and
application guidelines.
● Provide implementation hints and examples.
● Illustrate class and object relationships.
Goal of Design Patterns
● Understand the problem and matching it with
some pattern
● Making the present design reusable for the
future usage
● Speed up development with proven
approaches.
As the name façade suggests, it means
"the face of the building."
Façade Pattern
Analogy
● A glass face of a building hides its complexities from passersby.
● Similarly, the facade design pattern conceals system complexities.
● The facade pattern uses a single class with simplified methods for client interaction.
● It delegates calls to existing system class methods.
● When placing a phone order, the operator serves as a facade.
● The operator offers a simple voice interface to shop services, payment, and delivery.
● Bank sample
Pronunciation is /fəˈsɑːd/
A part of Gang of Four
design patterns (23 others).
It comes under the
“Structural” category.
Diagrams
03
Visual representation of the pattern's
structural diagram.
Structural Diagram 1
Structural Diagram 2
Applicability
04
When to apply the Façade pattern in
software design?
● Facade pattern simplifies access to complex
subsystems.
● Subsystems tend to become more complex over
time, leading to smaller classes.
● Facade pattern enhances subsystem reusability
and customization but can complicate things for
non-customizing clients.
● Facades provide a default view for most clients,
allowing customization for those who need it.
● Facades separate subsystems from clients and
other subsystems, promoting independence and
portability.
● Use facades as entry points for subsystems to
simplify interactions between dependent
subsystems.
Applicability
● Facade simplifies client-subsystem interactions.
● Promotes loose coupling between subsystem
and clients, allowing changes without impacting
clients.
● Helps manage complex dependencies and
circular relationships in a system.
● Reduces compilation dependencies in large
software systems, saving time when making
changes.
● Eases porting to other platforms by minimizing
dependencies.
● Doesn't prevent direct use of subsystem classes
when needed, providing flexibility for clients.
Consequences
Sample Code
05
How clients interact with the Façade and
some codes.
Sample Code
from __future__ import annotations
class Facade:
"""
The Facade class provides a simple interface to the complex logic of one or
several subsystems. The Facade delegates the client requests to the
appropriate objects within the subsystem. The Facade is also responsible for
managing their lifecycle. All of this shields the client from the undesired
complexity of the subsystem.
"""
def __init__(self, subsystem1: Subsystem1, subsystem2: Subsystem2) -> None:
"""
Depending on your application's needs, you can provide the Facade with
existing subsystem objects or force the Facade to create them on its
own.
"""
self._subsystem1 = subsystem1 or Subsystem1()
self._subsystem2 = subsystem2 or Subsystem2()
Sample Code (Contd)
class Facade:
def operation(self) -> str:
"""
The Facade's methods are convenient shortcuts to the sophisticated
functionality of the subsystems. However, clients get only to a fraction
of a subsystem's capabilities.
"""
results = []
results.append("Facade initializes subsystems:" )
results.append(self._subsystem1.operation1())
results.append(self._subsystem2.operation1())
results.append("Facade orders subsystems to perform the action:" )
results.append(self._subsystem1.operation_n())
results.append(self._subsystem2.operation_z())
return "n".join(results)
Sample Code (Contd)
class Subsystem1:
"""
The Subsystem can accept requests either from the facade or client directly.
In any case, to the Subsystem, the Facade is yet another client, and it's
not a part of the Subsystem.
"""
def operation1(self) -> str:
return "Subsystem1: Ready!"
# ...
def operation_n (self) -> str:
return "Subsystem1: Go!"
Sample Code (Contd)
class Subsystem2:
"""
Some facades can work with multiple subsystems at the same time.
"""
def operation1(self) -> str:
return "Subsystem2: Get ready!"
# ...
def operation_z (self) -> str:
return "Subsystem2: Fire!"
Sample Code (Contd)
def client_code (facade: Facade) -> None:
"""
The client code works with complex subsystems through a simple interface
provided by the Facade. When a facade manages the lifecycle of the
subsystem, the client might not even know about the existence of the
subsystem. This approach lets you keep the complexity under control.
"""
print(facade.operation(), end="")
if __name__ == "__main__":
# The client code may have some of the subsystem's objects already created.
# In this case, it might be worthwhile to initialize the Facade with these
# objects instead of letting the Facade create new instances.
subsystem1 = Subsystem1()
subsystem2 = Subsystem2()
facade = Facade(subsystem1, subsystem2)
client_code(facade)
Sample Code Output
Facade initializes subsystems:
Subsystem1: Ready!
Subsystem2: Get ready!
Facade orders subsystems to perform the action:
Subsystem1: Go!
Subsystem2: Fire!
Related Patterns
06
Abstract Factory, Mediator, Singleton
Related Patterns
Abstract Factory
● Work with Facade to create subsystem objects uniformly
and independently from the subsystem.
● Abstract Factory can also replace Facade to hide
platform-specific classes.
Mediator.
● Abstracts existing class functionality, but it centralizes
communication between colleague objects, keeping
functionality out of them
● colleagues communicate with the mediator, not directly with
each other, while in Facade, it simplifies subsystem object
interfaces but doesn't introduce new functionality.
Singleton
● T
ypically, only one Facade object is needed, often
implemented as a Singleton.
Resources
● Gamma, E., Helm, R., Johnson, R., Vlissides, J. and Patterns, D., 1995.
Elements of Reusable Object-Oriented Software. Design Patterns.
● https://refactoring.guru/design-patterns
● https://medium.com/backticks-tildes/the-s-o-l-i-d-principles-in-pic
tures-b34ce2f1e898
Thanks :)
Do you have any questions?
masoud@hbc.ir
smm.sadrn.com

Contenu connexe

Similaire à Facade Design Pattern

Sofwear deasign and need of design pattern
Sofwear deasign and need of design patternSofwear deasign and need of design pattern
Sofwear deasign and need of design patternchetankane
 
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
 
Introduction To Design Patterns
Introduction To Design PatternsIntroduction To Design Patterns
Introduction To Design Patternssukumarraju6
 
UNIT3 PART2.pptx dhfdifhdsfvgudf dhfbdhbffdvf
UNIT3 PART2.pptx dhfdifhdsfvgudf dhfbdhbffdvfUNIT3 PART2.pptx dhfdifhdsfvgudf dhfbdhbffdvf
UNIT3 PART2.pptx dhfdifhdsfvgudf dhfbdhbffdvfputtipavan23022023
 
Gof design pattern
Gof design patternGof design pattern
Gof design patternnaveen kumar
 
Android ppt with example of budget manager
Android ppt with example of budget managerAndroid ppt with example of budget manager
Android ppt with example of budget managerNalini Mehta
 
Tech challenges in a large scale agile project
Tech challenges in a large scale agile projectTech challenges in a large scale agile project
Tech challenges in a large scale agile projectHarald Soevik
 
Crafted Design - GeeCON 2014
Crafted Design - GeeCON 2014Crafted Design - GeeCON 2014
Crafted Design - GeeCON 2014Sandro Mancuso
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven DesignMuhammad Ali
 
Design pattern - Facade Pattern
Design pattern - Facade PatternDesign pattern - Facade Pattern
Design pattern - Facade PatternMudasir Qazi
 
A summary of software architecture guide
A summary of software architecture guideA summary of software architecture guide
A summary of software architecture guideTriet Ho
 

Similaire à Facade Design Pattern (20)

Ch09
Ch09Ch09
Ch09
 
Ch09
Ch09Ch09
Ch09
 
Sofwear deasign and need of design pattern
Sofwear deasign and need of design patternSofwear deasign and need of design pattern
Sofwear deasign and need of design pattern
 
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
 
Clean Architecture
Clean ArchitectureClean Architecture
Clean Architecture
 
Introduction To Design Patterns
Introduction To Design PatternsIntroduction To Design Patterns
Introduction To Design Patterns
 
Design engineering
Design engineeringDesign engineering
Design engineering
 
Design engineering
Design engineeringDesign engineering
Design engineering
 
UNIT3 PART2.pptx dhfdifhdsfvgudf dhfbdhbffdvf
UNIT3 PART2.pptx dhfdifhdsfvgudf dhfbdhbffdvfUNIT3 PART2.pptx dhfdifhdsfvgudf dhfbdhbffdvf
UNIT3 PART2.pptx dhfdifhdsfvgudf dhfbdhbffdvf
 
Gof design pattern
Gof design patternGof design pattern
Gof design pattern
 
Android ppt with example of budget manager
Android ppt with example of budget managerAndroid ppt with example of budget manager
Android ppt with example of budget manager
 
Tech challenges in a large scale agile project
Tech challenges in a large scale agile projectTech challenges in a large scale agile project
Tech challenges in a large scale agile project
 
Crafted Design - GeeCON 2014
Crafted Design - GeeCON 2014Crafted Design - GeeCON 2014
Crafted Design - GeeCON 2014
 
06 fse design
06 fse design06 fse design
06 fse design
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Gof design patterns
Gof design patternsGof design patterns
Gof design patterns
 
Design pattern - Facade Pattern
Design pattern - Facade PatternDesign pattern - Facade Pattern
Design pattern - Facade Pattern
 
Design pattern
Design patternDesign pattern
Design pattern
 
Software design
Software designSoftware design
Software design
 
A summary of software architecture guide
A summary of software architecture guideA summary of software architecture guide
A summary of software architecture guide
 

Plus de S. M. Masoud Sadrnezhaad

استفاده از داده‌های تجربی برای پشتیبانی از انتخاب فناوری در تصمیم‌گیری معماری...
استفاده از داده‌های تجربی برای پشتیبانی از انتخاب فناوری در تصمیم‌گیری معماری...استفاده از داده‌های تجربی برای پشتیبانی از انتخاب فناوری در تصمیم‌گیری معماری...
استفاده از داده‌های تجربی برای پشتیبانی از انتخاب فناوری در تصمیم‌گیری معماری...S. M. Masoud Sadrnezhaad
 
تاریخچه و پیشینهٔ نظری اندازه‌گیری عملکرد و معرفی اجمالی برخی مدل‌های بلوغ و ...
تاریخچه و پیشینهٔ نظری اندازه‌گیری عملکرد و معرفی اجمالی برخی مدل‌های بلوغ و ...تاریخچه و پیشینهٔ نظری اندازه‌گیری عملکرد و معرفی اجمالی برخی مدل‌های بلوغ و ...
تاریخچه و پیشینهٔ نظری اندازه‌گیری عملکرد و معرفی اجمالی برخی مدل‌های بلوغ و ...S. M. Masoud Sadrnezhaad
 
تحلیل بده‌بستان‌ها میان ویژگی‌های کیفی برای پشتیبانی از تصمیم‌های معماری نرم‌...
تحلیل بده‌بستان‌ها میان ویژگی‌های کیفی برای پشتیبانی از تصمیم‌های معماری نرم‌...تحلیل بده‌بستان‌ها میان ویژگی‌های کیفی برای پشتیبانی از تصمیم‌های معماری نرم‌...
تحلیل بده‌بستان‌ها میان ویژگی‌های کیفی برای پشتیبانی از تصمیم‌های معماری نرم‌...S. M. Masoud Sadrnezhaad
 
سامانهٔ پشتیبان تصمیم برای شناسایی معماری‌های نامزد و اتخاذ تصمیم‌های معماری ...
سامانهٔ پشتیبان تصمیم برای شناسایی معماری‌های نامزد و اتخاذ تصمیم‌های معماری ...سامانهٔ پشتیبان تصمیم برای شناسایی معماری‌های نامزد و اتخاذ تصمیم‌های معماری ...
سامانهٔ پشتیبان تصمیم برای شناسایی معماری‌های نامزد و اتخاذ تصمیم‌های معماری ...S. M. Masoud Sadrnezhaad
 
آماده‌سازی ذهن برای خلاقیت و ابزار داستان‌سرایی
آماده‌سازی ذهن برای خلاقیت و ابزار داستان‌سراییآماده‌سازی ذهن برای خلاقیت و ابزار داستان‌سرایی
آماده‌سازی ذهن برای خلاقیت و ابزار داستان‌سراییS. M. Masoud Sadrnezhaad
 
نمایش اجرای فرایندهای حرفه به کمک ابزارهای پویانمایی و شبیه‌سازی زمان و هزینه...
نمایش اجرای فرایندهای حرفه به کمک ابزارهای پویانمایی و شبیه‌سازی زمان و هزینه...نمایش اجرای فرایندهای حرفه به کمک ابزارهای پویانمایی و شبیه‌سازی زمان و هزینه...
نمایش اجرای فرایندهای حرفه به کمک ابزارهای پویانمایی و شبیه‌سازی زمان و هزینه...S. M. Masoud Sadrnezhaad
 
چارچوب توصیف منبع برای ذخیره و بازیابی معنا
چارچوب توصیف منبع برای ذخیره و بازیابی معناچارچوب توصیف منبع برای ذخیره و بازیابی معنا
چارچوب توصیف منبع برای ذخیره و بازیابی معناS. M. Masoud Sadrnezhaad
 
حوزه‌های پژوهش در زمینهٔ مهندسی نرم‌افزار سامانه‌های خودتطبیق و خودسازمانده
حوزه‌های پژوهش در زمینهٔ مهندسی نرم‌افزار سامانه‌های خودتطبیق و خودسازماندهحوزه‌های پژوهش در زمینهٔ مهندسی نرم‌افزار سامانه‌های خودتطبیق و خودسازمانده
حوزه‌های پژوهش در زمینهٔ مهندسی نرم‌افزار سامانه‌های خودتطبیق و خودسازماندهS. M. Masoud Sadrnezhaad
 
معرفی و اجرای سناریوی SWIM در چارچوب Rainbow برای شبیه‌سازی معماری نرم‌افزار ...
معرفی و اجرای سناریوی SWIM در چارچوب Rainbow برای شبیه‌سازی معماری نرم‌افزار ...معرفی و اجرای سناریوی SWIM در چارچوب Rainbow برای شبیه‌سازی معماری نرم‌افزار ...
معرفی و اجرای سناریوی SWIM در چارچوب Rainbow برای شبیه‌سازی معماری نرم‌افزار ...S. M. Masoud Sadrnezhaad
 
معرفی و آموزش نحوهٔ استفاده از نرم‌افزار ERPNext برای برنامه‌ریزی منابع سازمانی
معرفی و آموزش نحوهٔ استفاده از نرم‌افزار ERPNext برای برنامه‌ریزی منابع سازمانیمعرفی و آموزش نحوهٔ استفاده از نرم‌افزار ERPNext برای برنامه‌ریزی منابع سازمانی
معرفی و آموزش نحوهٔ استفاده از نرم‌افزار ERPNext برای برنامه‌ریزی منابع سازمانیS. M. Masoud Sadrnezhaad
 
بی‌طرفی شبکه و ریشه‌های آن
بی‌طرفی شبکه و ریشه‌های آنبی‌طرفی شبکه و ریشه‌های آن
بی‌طرفی شبکه و ریشه‌های آنS. M. Masoud Sadrnezhaad
 
از فرهنگ اجازه تا فرهنگ آزاد یا چگونه رسانه‌ها از تکنولوژی و قانون برای محدود...
از فرهنگ اجازه تا فرهنگ آزاد یا چگونه رسانه‌ها از تکنولوژی و قانون برای محدود...از فرهنگ اجازه تا فرهنگ آزاد یا چگونه رسانه‌ها از تکنولوژی و قانون برای محدود...
از فرهنگ اجازه تا فرهنگ آزاد یا چگونه رسانه‌ها از تکنولوژی و قانون برای محدود...S. M. Masoud Sadrnezhaad
 
طراحی و معماری خدمات ابری زیرساخت آمازون (AWS)
طراحی و معماری خدمات ابری زیرساخت آمازون (AWS)طراحی و معماری خدمات ابری زیرساخت آمازون (AWS)
طراحی و معماری خدمات ابری زیرساخت آمازون (AWS)S. M. Masoud Sadrnezhaad
 
معرفی و آموزش سامانهٔ مدیریت محتوا مزانین
معرفی و آموزش سامانهٔ مدیریت محتوا مزانینمعرفی و آموزش سامانهٔ مدیریت محتوا مزانین
معرفی و آموزش سامانهٔ مدیریت محتوا مزانینS. M. Masoud Sadrnezhaad
 
نقش جامعه و دولت در حمایت از نرم‌افزار آزاد
نقش جامعه و دولت در حمایت از نرم‌افزار آزادنقش جامعه و دولت در حمایت از نرم‌افزار آزاد
نقش جامعه و دولت در حمایت از نرم‌افزار آزادS. M. Masoud Sadrnezhaad
 
بزرگ‌داده؛ مقیاسی از دنیای واقعی
بزرگ‌داده؛ مقیاسی از دنیای واقعیبزرگ‌داده؛ مقیاسی از دنیای واقعی
بزرگ‌داده؛ مقیاسی از دنیای واقعیS. M. Masoud Sadrnezhaad
 

Plus de S. M. Masoud Sadrnezhaad (20)

Epistemic Justification
Epistemic JustificationEpistemic Justification
Epistemic Justification
 
استفاده از داده‌های تجربی برای پشتیبانی از انتخاب فناوری در تصمیم‌گیری معماری...
استفاده از داده‌های تجربی برای پشتیبانی از انتخاب فناوری در تصمیم‌گیری معماری...استفاده از داده‌های تجربی برای پشتیبانی از انتخاب فناوری در تصمیم‌گیری معماری...
استفاده از داده‌های تجربی برای پشتیبانی از انتخاب فناوری در تصمیم‌گیری معماری...
 
تاریخچه و پیشینهٔ نظری اندازه‌گیری عملکرد و معرفی اجمالی برخی مدل‌های بلوغ و ...
تاریخچه و پیشینهٔ نظری اندازه‌گیری عملکرد و معرفی اجمالی برخی مدل‌های بلوغ و ...تاریخچه و پیشینهٔ نظری اندازه‌گیری عملکرد و معرفی اجمالی برخی مدل‌های بلوغ و ...
تاریخچه و پیشینهٔ نظری اندازه‌گیری عملکرد و معرفی اجمالی برخی مدل‌های بلوغ و ...
 
تحلیل بده‌بستان‌ها میان ویژگی‌های کیفی برای پشتیبانی از تصمیم‌های معماری نرم‌...
تحلیل بده‌بستان‌ها میان ویژگی‌های کیفی برای پشتیبانی از تصمیم‌های معماری نرم‌...تحلیل بده‌بستان‌ها میان ویژگی‌های کیفی برای پشتیبانی از تصمیم‌های معماری نرم‌...
تحلیل بده‌بستان‌ها میان ویژگی‌های کیفی برای پشتیبانی از تصمیم‌های معماری نرم‌...
 
سامانهٔ پشتیبان تصمیم برای شناسایی معماری‌های نامزد و اتخاذ تصمیم‌های معماری ...
سامانهٔ پشتیبان تصمیم برای شناسایی معماری‌های نامزد و اتخاذ تصمیم‌های معماری ...سامانهٔ پشتیبان تصمیم برای شناسایی معماری‌های نامزد و اتخاذ تصمیم‌های معماری ...
سامانهٔ پشتیبان تصمیم برای شناسایی معماری‌های نامزد و اتخاذ تصمیم‌های معماری ...
 
آماده‌سازی ذهن برای خلاقیت و ابزار داستان‌سرایی
آماده‌سازی ذهن برای خلاقیت و ابزار داستان‌سراییآماده‌سازی ذهن برای خلاقیت و ابزار داستان‌سرایی
آماده‌سازی ذهن برای خلاقیت و ابزار داستان‌سرایی
 
نمایش اجرای فرایندهای حرفه به کمک ابزارهای پویانمایی و شبیه‌سازی زمان و هزینه...
نمایش اجرای فرایندهای حرفه به کمک ابزارهای پویانمایی و شبیه‌سازی زمان و هزینه...نمایش اجرای فرایندهای حرفه به کمک ابزارهای پویانمایی و شبیه‌سازی زمان و هزینه...
نمایش اجرای فرایندهای حرفه به کمک ابزارهای پویانمایی و شبیه‌سازی زمان و هزینه...
 
چارچوب توصیف منبع برای ذخیره و بازیابی معنا
چارچوب توصیف منبع برای ذخیره و بازیابی معناچارچوب توصیف منبع برای ذخیره و بازیابی معنا
چارچوب توصیف منبع برای ذخیره و بازیابی معنا
 
حوزه‌های پژوهش در زمینهٔ مهندسی نرم‌افزار سامانه‌های خودتطبیق و خودسازمانده
حوزه‌های پژوهش در زمینهٔ مهندسی نرم‌افزار سامانه‌های خودتطبیق و خودسازماندهحوزه‌های پژوهش در زمینهٔ مهندسی نرم‌افزار سامانه‌های خودتطبیق و خودسازمانده
حوزه‌های پژوهش در زمینهٔ مهندسی نرم‌افزار سامانه‌های خودتطبیق و خودسازمانده
 
معرفی و اجرای سناریوی SWIM در چارچوب Rainbow برای شبیه‌سازی معماری نرم‌افزار ...
معرفی و اجرای سناریوی SWIM در چارچوب Rainbow برای شبیه‌سازی معماری نرم‌افزار ...معرفی و اجرای سناریوی SWIM در چارچوب Rainbow برای شبیه‌سازی معماری نرم‌افزار ...
معرفی و اجرای سناریوی SWIM در چارچوب Rainbow برای شبیه‌سازی معماری نرم‌افزار ...
 
معرفی و آموزش نحوهٔ استفاده از نرم‌افزار ERPNext برای برنامه‌ریزی منابع سازمانی
معرفی و آموزش نحوهٔ استفاده از نرم‌افزار ERPNext برای برنامه‌ریزی منابع سازمانیمعرفی و آموزش نحوهٔ استفاده از نرم‌افزار ERPNext برای برنامه‌ریزی منابع سازمانی
معرفی و آموزش نحوهٔ استفاده از نرم‌افزار ERPNext برای برنامه‌ریزی منابع سازمانی
 
بی‌طرفی شبکه و ریشه‌های آن
بی‌طرفی شبکه و ریشه‌های آنبی‌طرفی شبکه و ریشه‌های آن
بی‌طرفی شبکه و ریشه‌های آن
 
Git Version Control System Part 2
 Git Version Control System Part 2 Git Version Control System Part 2
Git Version Control System Part 2
 
Classroom Object Oriented Language (COOL)
Classroom Object Oriented Language (COOL)Classroom Object Oriented Language (COOL)
Classroom Object Oriented Language (COOL)
 
از فرهنگ اجازه تا فرهنگ آزاد یا چگونه رسانه‌ها از تکنولوژی و قانون برای محدود...
از فرهنگ اجازه تا فرهنگ آزاد یا چگونه رسانه‌ها از تکنولوژی و قانون برای محدود...از فرهنگ اجازه تا فرهنگ آزاد یا چگونه رسانه‌ها از تکنولوژی و قانون برای محدود...
از فرهنگ اجازه تا فرهنگ آزاد یا چگونه رسانه‌ها از تکنولوژی و قانون برای محدود...
 
طراحی و معماری خدمات ابری زیرساخت آمازون (AWS)
طراحی و معماری خدمات ابری زیرساخت آمازون (AWS)طراحی و معماری خدمات ابری زیرساخت آمازون (AWS)
طراحی و معماری خدمات ابری زیرساخت آمازون (AWS)
 
معرفی و آموزش سامانهٔ مدیریت محتوا مزانین
معرفی و آموزش سامانهٔ مدیریت محتوا مزانینمعرفی و آموزش سامانهٔ مدیریت محتوا مزانین
معرفی و آموزش سامانهٔ مدیریت محتوا مزانین
 
Git Version Control System
Git Version Control SystemGit Version Control System
Git Version Control System
 
نقش جامعه و دولت در حمایت از نرم‌افزار آزاد
نقش جامعه و دولت در حمایت از نرم‌افزار آزادنقش جامعه و دولت در حمایت از نرم‌افزار آزاد
نقش جامعه و دولت در حمایت از نرم‌افزار آزاد
 
بزرگ‌داده؛ مقیاسی از دنیای واقعی
بزرگ‌داده؛ مقیاسی از دنیای واقعیبزرگ‌داده؛ مقیاسی از دنیای واقعی
بزرگ‌داده؛ مقیاسی از دنیای واقعی
 

Dernier

[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypseTomasz Kowalczewski
 
WSO2Con2024 - Unleashing the Financial Potential of 13 Million People
WSO2Con2024 - Unleashing the Financial Potential of 13 Million PeopleWSO2Con2024 - Unleashing the Financial Potential of 13 Million People
WSO2Con2024 - Unleashing the Financial Potential of 13 Million PeopleWSO2
 
WSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - KanchanaWSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - KanchanaWSO2
 
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of TransformationWSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of TransformationWSO2
 
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public AdministrationWSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public AdministrationWSO2
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
WSO2Con2024 - Simplified Integration: Unveiling the Latest Features in WSO2 L...
WSO2Con2024 - Simplified Integration: Unveiling the Latest Features in WSO2 L...WSO2Con2024 - Simplified Integration: Unveiling the Latest Features in WSO2 L...
WSO2Con2024 - Simplified Integration: Unveiling the Latest Features in WSO2 L...WSO2
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public AdministrationWSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public AdministrationWSO2
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
WSO2CON 2024 - OSU & WSO2: A Decade Journey in Integration & Innovation
WSO2CON 2024 - OSU & WSO2: A Decade Journey in Integration & InnovationWSO2CON 2024 - OSU & WSO2: A Decade Journey in Integration & Innovation
WSO2CON 2024 - OSU & WSO2: A Decade Journey in Integration & InnovationWSO2
 
BusinessGPT - Security and Governance for Generative AI
BusinessGPT  - Security and Governance for Generative AIBusinessGPT  - Security and Governance for Generative AI
BusinessGPT - Security and Governance for Generative AIAGATSoftware
 
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...WSO2
 
WSO2CON 2024 Slides - Unlocking Value with AI
WSO2CON 2024 Slides - Unlocking Value with AIWSO2CON 2024 Slides - Unlocking Value with AI
WSO2CON 2024 Slides - Unlocking Value with AIWSO2
 
WSO2Con2024 - Low-Code Integration Tooling
WSO2Con2024 - Low-Code Integration ToolingWSO2Con2024 - Low-Code Integration Tooling
WSO2Con2024 - Low-Code Integration ToolingWSO2
 
Driving Innovation: Scania's API Revolution with WSO2
Driving Innovation: Scania's API Revolution with WSO2Driving Innovation: Scania's API Revolution with WSO2
Driving Innovation: Scania's API Revolution with WSO2WSO2
 

Dernier (20)

[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
 
WSO2Con2024 - Unleashing the Financial Potential of 13 Million People
WSO2Con2024 - Unleashing the Financial Potential of 13 Million PeopleWSO2Con2024 - Unleashing the Financial Potential of 13 Million People
WSO2Con2024 - Unleashing the Financial Potential of 13 Million People
 
WSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - KanchanaWSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - Kanchana
 
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of TransformationWSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
 
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public AdministrationWSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
WSO2Con2024 - Simplified Integration: Unveiling the Latest Features in WSO2 L...
WSO2Con2024 - Simplified Integration: Unveiling the Latest Features in WSO2 L...WSO2Con2024 - Simplified Integration: Unveiling the Latest Features in WSO2 L...
WSO2Con2024 - Simplified Integration: Unveiling the Latest Features in WSO2 L...
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public AdministrationWSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
WSO2CON 2024 - OSU & WSO2: A Decade Journey in Integration & Innovation
WSO2CON 2024 - OSU & WSO2: A Decade Journey in Integration & InnovationWSO2CON 2024 - OSU & WSO2: A Decade Journey in Integration & Innovation
WSO2CON 2024 - OSU & WSO2: A Decade Journey in Integration & Innovation
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
BusinessGPT - Security and Governance for Generative AI
BusinessGPT  - Security and Governance for Generative AIBusinessGPT  - Security and Governance for Generative AI
BusinessGPT - Security and Governance for Generative AI
 
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
 
WSO2CON 2024 Slides - Unlocking Value with AI
WSO2CON 2024 Slides - Unlocking Value with AIWSO2CON 2024 Slides - Unlocking Value with AI
WSO2CON 2024 Slides - Unlocking Value with AI
 
WSO2Con2024 - Low-Code Integration Tooling
WSO2Con2024 - Low-Code Integration ToolingWSO2Con2024 - Low-Code Integration Tooling
WSO2Con2024 - Low-Code Integration Tooling
 
Driving Innovation: Scania's API Revolution with WSO2
Driving Innovation: Scania's API Revolution with WSO2Driving Innovation: Scania's API Revolution with WSO2
Driving Innovation: Scania's API Revolution with WSO2
 

Facade Design Pattern

  • 2. Table of contents When to apply the Façade pattern in software design? Classes, Instances, States, SOLID Principles Exploring the concept and purpose of façade pattern. How clients interact with the Façade and some codes. Visual representation of the pattern's structural diagram Abstract Factory, Mediator, Singleton 01 04 02 05 03 06 Object-Oriented Introduction Diagrams Applicability Sample Code Related Patterns
  • 9. Introduction 02 Exploring the concept and purpose of façade pattern.
  • 10. Design Patterns Design Patterns ● Best practices for software development recurring design problems ● Includes problem descriptions, solutions, and application guidelines. ● Provide implementation hints and examples. ● Illustrate class and object relationships. Goal of Design Patterns ● Understand the problem and matching it with some pattern ● Making the present design reusable for the future usage ● Speed up development with proven approaches.
  • 11. As the name façade suggests, it means "the face of the building."
  • 12. Façade Pattern Analogy ● A glass face of a building hides its complexities from passersby. ● Similarly, the facade design pattern conceals system complexities. ● The facade pattern uses a single class with simplified methods for client interaction. ● It delegates calls to existing system class methods. ● When placing a phone order, the operator serves as a facade. ● The operator offers a simple voice interface to shop services, payment, and delivery. ● Bank sample Pronunciation is /fəˈsɑːd/ A part of Gang of Four design patterns (23 others). It comes under the “Structural” category.
  • 13. Diagrams 03 Visual representation of the pattern's structural diagram.
  • 16. Applicability 04 When to apply the Façade pattern in software design?
  • 17. ● Facade pattern simplifies access to complex subsystems. ● Subsystems tend to become more complex over time, leading to smaller classes. ● Facade pattern enhances subsystem reusability and customization but can complicate things for non-customizing clients. ● Facades provide a default view for most clients, allowing customization for those who need it. ● Facades separate subsystems from clients and other subsystems, promoting independence and portability. ● Use facades as entry points for subsystems to simplify interactions between dependent subsystems. Applicability
  • 18. ● Facade simplifies client-subsystem interactions. ● Promotes loose coupling between subsystem and clients, allowing changes without impacting clients. ● Helps manage complex dependencies and circular relationships in a system. ● Reduces compilation dependencies in large software systems, saving time when making changes. ● Eases porting to other platforms by minimizing dependencies. ● Doesn't prevent direct use of subsystem classes when needed, providing flexibility for clients. Consequences
  • 19. Sample Code 05 How clients interact with the Façade and some codes.
  • 20. Sample Code from __future__ import annotations class Facade: """ The Facade class provides a simple interface to the complex logic of one or several subsystems. The Facade delegates the client requests to the appropriate objects within the subsystem. The Facade is also responsible for managing their lifecycle. All of this shields the client from the undesired complexity of the subsystem. """ def __init__(self, subsystem1: Subsystem1, subsystem2: Subsystem2) -> None: """ Depending on your application's needs, you can provide the Facade with existing subsystem objects or force the Facade to create them on its own. """ self._subsystem1 = subsystem1 or Subsystem1() self._subsystem2 = subsystem2 or Subsystem2()
  • 21. Sample Code (Contd) class Facade: def operation(self) -> str: """ The Facade's methods are convenient shortcuts to the sophisticated functionality of the subsystems. However, clients get only to a fraction of a subsystem's capabilities. """ results = [] results.append("Facade initializes subsystems:" ) results.append(self._subsystem1.operation1()) results.append(self._subsystem2.operation1()) results.append("Facade orders subsystems to perform the action:" ) results.append(self._subsystem1.operation_n()) results.append(self._subsystem2.operation_z()) return "n".join(results)
  • 22. Sample Code (Contd) class Subsystem1: """ The Subsystem can accept requests either from the facade or client directly. In any case, to the Subsystem, the Facade is yet another client, and it's not a part of the Subsystem. """ def operation1(self) -> str: return "Subsystem1: Ready!" # ... def operation_n (self) -> str: return "Subsystem1: Go!"
  • 23. Sample Code (Contd) class Subsystem2: """ Some facades can work with multiple subsystems at the same time. """ def operation1(self) -> str: return "Subsystem2: Get ready!" # ... def operation_z (self) -> str: return "Subsystem2: Fire!"
  • 24. Sample Code (Contd) def client_code (facade: Facade) -> None: """ The client code works with complex subsystems through a simple interface provided by the Facade. When a facade manages the lifecycle of the subsystem, the client might not even know about the existence of the subsystem. This approach lets you keep the complexity under control. """ print(facade.operation(), end="") if __name__ == "__main__": # The client code may have some of the subsystem's objects already created. # In this case, it might be worthwhile to initialize the Facade with these # objects instead of letting the Facade create new instances. subsystem1 = Subsystem1() subsystem2 = Subsystem2() facade = Facade(subsystem1, subsystem2) client_code(facade)
  • 25. Sample Code Output Facade initializes subsystems: Subsystem1: Ready! Subsystem2: Get ready! Facade orders subsystems to perform the action: Subsystem1: Go! Subsystem2: Fire!
  • 27. Related Patterns Abstract Factory ● Work with Facade to create subsystem objects uniformly and independently from the subsystem. ● Abstract Factory can also replace Facade to hide platform-specific classes. Mediator. ● Abstracts existing class functionality, but it centralizes communication between colleague objects, keeping functionality out of them ● colleagues communicate with the mediator, not directly with each other, while in Facade, it simplifies subsystem object interfaces but doesn't introduce new functionality. Singleton ● T ypically, only one Facade object is needed, often implemented as a Singleton.
  • 28. Resources ● Gamma, E., Helm, R., Johnson, R., Vlissides, J. and Patterns, D., 1995. Elements of Reusable Object-Oriented Software. Design Patterns. ● https://refactoring.guru/design-patterns ● https://medium.com/backticks-tildes/the-s-o-l-i-d-principles-in-pic tures-b34ce2f1e898
  • 29. Thanks :) Do you have any questions? masoud@hbc.ir smm.sadrn.com