SlideShare a Scribd company logo
1 of 22
Object Oriented Programming
Design Patterns
The Adapter Pattern
An example of Object Oriented PHP
Implementation for
< https://www.drupal.org/project/oop_design_patterns >
OOP Design Patterns
Links
Drupal.org: VicOnt, nafes
Presentation Code:
https://www.drupal.org/project/oop_design_patterns
https://www.drupal.org/project/oop_examples
< https://www.drupal.org/project/oop_design_patterns >
OOP Design Patterns: The Gang of Four!
It all started around 1994 when a group of 4 IBM programmers:
Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides
based on their coding experience , were able to observe and document
a set of about 23 common problems and their best accepted solutions
< https://www.drupal.org/project/oop_design_patterns >
OOP Design Patterns
What are design patterns?
Recurring solutions to common software development challenges
< https://www.drupal.org/project/oop_design_patterns >
O
OOP Design Patterns
Some common software development challenges:
➢ Building new applications while leveraging existing codebases
➢ Building/enhancing applications securely, quickly and effectively
➢ Integrating new and existing applications
➢ Multiple developers programming the same product
➢ Few developers programming many products
➢ Varying, sometimes unknown, data sources, OS, Setups
< https://www.drupal.org/project/oop_design_patterns >
OOP Design Patterns
What are design patterns not?
a) They are not the end to all of your coding challenges.
b) They are not a requirement of object oriented programming.
c) They are not a substitute for application code and logic.
d) They are not always the best solution for the job.
e) They are not always the easiest concept to grasp and/or use.
< https://www.drupal.org/project/oop_design_patterns >
b) DDT DRY DOT OnceAndOnlyOnce KISS/YAGNI PARETO
Don’t Do Twice Don’t Repeat Yourself Do One Thing Each and every declaration of behavior should appear Once (For) You ain't gonna need it 80effort/20functionality
normalization in the RelationalModel and removing redundancies 80%of code is crap
Programmers’ Code, Rule #27, Rules are best broken by those who have mastered them
OOP Design Patterns
GOF Classification for patterns
Creational
What: deal with object creation mechanisms
How: somehow controlling the object
creation
Example: Abstract Factory
Create a series of related objects without
specifying their distinct classes.
Usually all classes implements the same
interface.
< https://www.drupal.org/project/oop_design_patterns >
Structural
What: ease/simplify the design
How: by identifying a simple way to realize
relationships between entities.
Example: Adapter/Wrapper
Translate one interface for a class into a
compatible interface –by providing it’s interface
to clients while using the original interface.
Behavioral
What: identify common communication
patterns between objects
How: realizing these patterns
Example: Template Method
A skeleton of an algorithm, well-suited for
framework libraries. The user implements
one method and the superclass do the job.
OOP Design Patterns
The Adapter Pattern
Purpose: allows the interface of an existing class to be used from another
interface. It is often used to make existing classes work with others without
modifying their source code.
Examples where Adapter Pattern may help:
• I want to add search capabilities to my application and support
multiple search engines such as Google, Yahoo, Bing…
• Have an image loader for different kinds of images JPG, GIF, PNG…
• Use different Email providers: Gmail, Hotmail, YahooMail…
• Use different data sources: Db, XML, TXT, CSV…
• Connect to different Db: MySQL, PostgreSQL, MSSQL, Oracle
• Have multiple downloads using different protocols: HTTP, HTTPS, FTP…
• Use different payment providers: Moneris, AuthorizeNet, Skrill…
< https://www.drupal.org/project/oop_design_patterns >
OOP Design Patterns
If Client and Adaptee are incompatible, we may create
a new class called Adapter, and place it in between
Target and Adaptee.
Components become compatible with each other
through Adapter.
As long as some component integrates incompatible
interfaces, it can be considered an adapter.
< https://www.drupal.org/project/oop_design_patterns >
Usually Adaptee class
implements
the Target interface.
Client and Adaptee
are compatible!
OOP Design Patterns
PHP Adapter: When you've opened a can of worms, then the
only way to seal them again - Is using a bigger jar
< https://www.drupal.org/project/oop_design_patterns >
The Interface
Incompatible
classes
OOP Design Patterns
Design patterns are a great way to modularize your code
and create reusable structures.
But they mean nothing if they go unused.
Go code something.
< https://www.drupal.org/project/oop_design_patterns >
OOP Design Patterns
The Problem: multiple Payment Providers
< https://www.drupal.org/project/oop_design_patterns >
OOP Design Patterns
The Solution: Adapter/Wrapper for Providers 1, 3
< https://www.drupal.org/project/oop_design_patterns >
Scope res op
OOP Design Patterns
The Solution: Adapter/Wrapper for Provider 2
< https://www.drupal.org/project/oop_design_patterns >
OOP Design Patterns
Adapter Pattern: UML diagram, programming to the interface
< https://www.drupal.org/project/oop_design_patterns >
OOP Design Patterns
Adapter Pattern: Easy of use, programming to the interface
OOP Design Patterns
Adapter Pattern: Drupal 7 implementation
< https://www.drupal.org/project/oop_design_patterns >
OOP Design Patterns
Adapter Pattern: Drupal 8 implementation
< https://www.drupal.org/project/oop_design_patterns >
OOP Design Patterns
CodeCase in action:
< https://www.drupal.org/project/oop_design_patterns >
OOP Design Patterns
CodeCase in action:
< https://www.drupal.org/project/oop_design_patterns >
OOP Design Patterns
To be Continued...
Controller (GenRespAsignSoftPatt), Facade (GOF)
➢ Probably one of the most common patterns in OOP
➢ One of the most powerful patterns in development
➢ Opens a wealth of new possibilities, when understood
➢ Very flexible when favoring composition over inheritance
➢ Encapsulates what changes to allow for greater extendability
< https://www.drupal.org/project/oop_design_patterns >
OOP Design Patterns
Acknowledgments
Donquixote (Andreas Hennings)
For PHP Class loading suite (PSR-4)
https://www.drupal.org/project/xautoload
Nafes (Nik Alexandrov)
For Starting OOP examples in Drupal
https://www.drupal.org/project/oop_examples
< https://www.drupal.org/project/oop_design_patterns >

More Related Content

What's hot

Software Design Patterns. Part I :: Structural Patterns
Software Design Patterns. Part I :: Structural PatternsSoftware Design Patterns. Part I :: Structural Patterns
Software Design Patterns. Part I :: Structural PatternsSergey Aganezov
 
Eclipse and Java 8 - Eclipse Day India 2013
Eclipse and Java 8 - Eclipse Day India 2013Eclipse and Java 8 - Eclipse Day India 2013
Eclipse and Java 8 - Eclipse Day India 2013Noopur Gupta
 
Whats Newi in C# 8.0
Whats Newi in C# 8.0Whats Newi in C# 8.0
Whats Newi in C# 8.0Manoj Sharma
 
Design Patterns
Design PatternsDesign Patterns
Design Patternsimedo.de
 
PATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design PatternsPATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design PatternsMichael Heron
 
AOP-IOC made by Vi Quoc Hanh and Vu Cong Thanh in SC Team
AOP-IOC made by Vi Quoc Hanh and Vu Cong Thanh in SC TeamAOP-IOC made by Vi Quoc Hanh and Vu Cong Thanh in SC Team
AOP-IOC made by Vi Quoc Hanh and Vu Cong Thanh in SC TeamThuy_Dang
 
Code refactor strategy part #1
Code refactor strategy part #1Code refactor strategy part #1
Code refactor strategy part #1Tracy LOISEL
 
Scala - By Luu Thanh Thuy CWI team from eXo Platform SEA
Scala - By Luu Thanh Thuy CWI team from eXo Platform SEAScala - By Luu Thanh Thuy CWI team from eXo Platform SEA
Scala - By Luu Thanh Thuy CWI team from eXo Platform SEAThuy_Dang
 
Programming Paradigm & Languages
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & LanguagesGaditek
 
Angular4 getting started
Angular4 getting startedAngular4 getting started
Angular4 getting startedTejinderMakkar
 
The Economics of OptimJ
The Economics of OptimJThe Economics of OptimJ
The Economics of OptimJPatrick Viry
 
Solid principles, Design Patterns, and Domain Driven Design
Solid principles, Design Patterns, and Domain Driven DesignSolid principles, Design Patterns, and Domain Driven Design
Solid principles, Design Patterns, and Domain Driven DesignIrwansyah Irwansyah
 
Implementing DSLs in practice
Implementing DSLs in practiceImplementing DSLs in practice
Implementing DSLs in practiceMikhail Barash
 
Typescript overview
Typescript overviewTypescript overview
Typescript overviewThanvilahari
 
Aspect Oriented Programming
Aspect Oriented ProgrammingAspect Oriented Programming
Aspect Oriented ProgrammingRajesh Ganesan
 
Design Patterns - Factory Method & Abstract Factory
Design Patterns - Factory Method & Abstract FactoryDesign Patterns - Factory Method & Abstract Factory
Design Patterns - Factory Method & Abstract FactoryGuillermo Daniel Salazar
 

What's hot (20)

Software Design Patterns. Part I :: Structural Patterns
Software Design Patterns. Part I :: Structural PatternsSoftware Design Patterns. Part I :: Structural Patterns
Software Design Patterns. Part I :: Structural Patterns
 
Insight into java 1.8, OOP VS FP
Insight into java 1.8, OOP VS FPInsight into java 1.8, OOP VS FP
Insight into java 1.8, OOP VS FP
 
Spring AOP
Spring AOPSpring AOP
Spring AOP
 
Eclipse and Java 8 - Eclipse Day India 2013
Eclipse and Java 8 - Eclipse Day India 2013Eclipse and Java 8 - Eclipse Day India 2013
Eclipse and Java 8 - Eclipse Day India 2013
 
Whats Newi in C# 8.0
Whats Newi in C# 8.0Whats Newi in C# 8.0
Whats Newi in C# 8.0
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
PATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design PatternsPATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design Patterns
 
AOP-IOC made by Vi Quoc Hanh and Vu Cong Thanh in SC Team
AOP-IOC made by Vi Quoc Hanh and Vu Cong Thanh in SC TeamAOP-IOC made by Vi Quoc Hanh and Vu Cong Thanh in SC Team
AOP-IOC made by Vi Quoc Hanh and Vu Cong Thanh in SC Team
 
Code refactor strategy part #1
Code refactor strategy part #1Code refactor strategy part #1
Code refactor strategy part #1
 
Scala - By Luu Thanh Thuy CWI team from eXo Platform SEA
Scala - By Luu Thanh Thuy CWI team from eXo Platform SEAScala - By Luu Thanh Thuy CWI team from eXo Platform SEA
Scala - By Luu Thanh Thuy CWI team from eXo Platform SEA
 
Programming Paradigm & Languages
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & Languages
 
Angular4 getting started
Angular4 getting startedAngular4 getting started
Angular4 getting started
 
The Economics of OptimJ
The Economics of OptimJThe Economics of OptimJ
The Economics of OptimJ
 
Bridge pattern
Bridge patternBridge pattern
Bridge pattern
 
Solid principles, Design Patterns, and Domain Driven Design
Solid principles, Design Patterns, and Domain Driven DesignSolid principles, Design Patterns, and Domain Driven Design
Solid principles, Design Patterns, and Domain Driven Design
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Implementing DSLs in practice
Implementing DSLs in practiceImplementing DSLs in practice
Implementing DSLs in practice
 
Typescript overview
Typescript overviewTypescript overview
Typescript overview
 
Aspect Oriented Programming
Aspect Oriented ProgrammingAspect Oriented Programming
Aspect Oriented Programming
 
Design Patterns - Factory Method & Abstract Factory
Design Patterns - Factory Method & Abstract FactoryDesign Patterns - Factory Method & Abstract Factory
Design Patterns - Factory Method & Abstract Factory
 

Viewers also liked

Proxy & adapter pattern
Proxy & adapter patternProxy & adapter pattern
Proxy & adapter patternbabak danyal
 
Design Patterns Part1
Design Patterns  Part1Design Patterns  Part1
Design Patterns Part1Tom Chen
 
Design patterns structuralpatterns(theadapterpattern)
Design patterns structuralpatterns(theadapterpattern)Design patterns structuralpatterns(theadapterpattern)
Design patterns structuralpatterns(theadapterpattern)APU
 
The 23 gof design patterns in java ,the summary
The 23 gof design patterns in java ,the summaryThe 23 gof design patterns in java ,the summary
The 23 gof design patterns in java ,the summaryachraf_ing
 
Bridge pattern for Dummies
Bridge pattern for DummiesBridge pattern for Dummies
Bridge pattern for DummiesTaekSoon Jang
 
Design Patterns - 04 Adapter and Facade Pattern
Design Patterns - 04 Adapter and Facade PatternDesign Patterns - 04 Adapter and Facade Pattern
Design Patterns - 04 Adapter and Facade Patterneprafulla
 
Java Course 11: Design Patterns
Java Course 11: Design PatternsJava Course 11: Design Patterns
Java Course 11: Design PatternsAnton Keks
 
Design pattern tutorial
Design pattern tutorialDesign pattern tutorial
Design pattern tutorialPiyush Mittal
 
Let us understand design pattern
Let us understand design patternLet us understand design pattern
Let us understand design patternMindfire Solutions
 
Design Patterns
Design PatternsDesign Patterns
Design Patternssoms_1
 
Design patterns ppt
Design patterns pptDesign patterns ppt
Design patterns pptAman Jain
 
Design Patterns & JDK Examples
Design Patterns & JDK ExamplesDesign Patterns & JDK Examples
Design Patterns & JDK ExamplesEnder Aydin Orak
 
Design Patterns Illustrated
Design Patterns IllustratedDesign Patterns Illustrated
Design Patterns IllustratedHerman Peeren
 

Viewers also liked (17)

Proxy & adapter pattern
Proxy & adapter patternProxy & adapter pattern
Proxy & adapter pattern
 
Design Patterns Part1
Design Patterns  Part1Design Patterns  Part1
Design Patterns Part1
 
Design patterns structuralpatterns(theadapterpattern)
Design patterns structuralpatterns(theadapterpattern)Design patterns structuralpatterns(theadapterpattern)
Design patterns structuralpatterns(theadapterpattern)
 
The 23 gof design patterns in java ,the summary
The 23 gof design patterns in java ,the summaryThe 23 gof design patterns in java ,the summary
The 23 gof design patterns in java ,the summary
 
Design patterns - Adapter Pattern
Design patterns - Adapter PatternDesign patterns - Adapter Pattern
Design patterns - Adapter Pattern
 
Bridge pattern for Dummies
Bridge pattern for DummiesBridge pattern for Dummies
Bridge pattern for Dummies
 
Design Patterns - 04 Adapter and Facade Pattern
Design Patterns - 04 Adapter and Facade PatternDesign Patterns - 04 Adapter and Facade Pattern
Design Patterns - 04 Adapter and Facade Pattern
 
Java Course 11: Design Patterns
Java Course 11: Design PatternsJava Course 11: Design Patterns
Java Course 11: Design Patterns
 
Design pattern tutorial
Design pattern tutorialDesign pattern tutorial
Design pattern tutorial
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Let us understand design pattern
Let us understand design patternLet us understand design pattern
Let us understand design pattern
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Design patterns ppt
Design patterns pptDesign patterns ppt
Design patterns ppt
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Design Patterns & JDK Examples
Design Patterns & JDK ExamplesDesign Patterns & JDK Examples
Design Patterns & JDK Examples
 
Design Patterns (Examples in .NET)
Design Patterns (Examples in .NET)Design Patterns (Examples in .NET)
Design Patterns (Examples in .NET)
 
Design Patterns Illustrated
Design Patterns IllustratedDesign Patterns Illustrated
Design Patterns Illustrated
 

Similar to Adapter design-pattern2015

Building API's
Building API'sBuilding API's
Building API'sarcaneadam
 
GoF Design patterns I: Introduction + Structural Patterns
GoF Design patterns I:   Introduction + Structural PatternsGoF Design patterns I:   Introduction + Structural Patterns
GoF Design patterns I: Introduction + Structural PatternsSameh Deabes
 
Design pattern in an expressive language java script
Design pattern in an expressive language java scriptDesign pattern in an expressive language java script
Design pattern in an expressive language java scriptAmit Thakkar
 
Contributing to Drupal
Contributing to DrupalContributing to Drupal
Contributing to DrupalChris Skene
 
Design Patterns - General Introduction
Design Patterns - General IntroductionDesign Patterns - General Introduction
Design Patterns - General IntroductionAsma CHERIF
 
Become a better UX designer through code
Become a better UX designer through codeBecome a better UX designer through code
Become a better UX designer through codeRamon Lapenta
 
The Why and What of Pattern Lab
The Why and What of Pattern LabThe Why and What of Pattern Lab
The Why and What of Pattern LabDave Olsen
 
30 Skills to Master to Become a Senior Software Engineer
30 Skills to Master to Become a Senior Software Engineer30 Skills to Master to Become a Senior Software Engineer
30 Skills to Master to Become a Senior Software EngineerSean Coates
 
Vipul divyanshu mahout_documentation
Vipul divyanshu mahout_documentationVipul divyanshu mahout_documentation
Vipul divyanshu mahout_documentationVipul Divyanshu
 
Drupal Aware Design: Good Techniques for Better Themes
Drupal Aware Design: Good Techniques for Better ThemesDrupal Aware Design: Good Techniques for Better Themes
Drupal Aware Design: Good Techniques for Better Themesnyccamp
 
ContainerDayVietnam2016: Become a Cloud-native Developer
ContainerDayVietnam2016: Become a Cloud-native DeveloperContainerDayVietnam2016: Become a Cloud-native Developer
ContainerDayVietnam2016: Become a Cloud-native DeveloperDocker-Hanoi
 
The Drupal 7 Worst Practices Catalogue
The Drupal 7 Worst Practices CatalogueThe Drupal 7 Worst Practices Catalogue
The Drupal 7 Worst Practices CatalogueAlexandre Israël
 
Open agile is free and open source community agile-
Open agile  is free and open source community agile-Open agile  is free and open source community agile-
Open agile is free and open source community agile-Agile Tour Beirut
 
Presentation 1 Web--dev
Presentation 1 Web--devPresentation 1 Web--dev
Presentation 1 Web--devaltsav
 
Making the Most of Modern PHP in Drupal 7
Making the Most of Modern PHP in Drupal 7Making the Most of Modern PHP in Drupal 7
Making the Most of Modern PHP in Drupal 7Ryan Szrama
 
Contributing to drupal
Contributing to drupalContributing to drupal
Contributing to drupalmarcingy
 
Some Cool Design Patterns, Practices, and Principles
Some Cool Design Patterns, Practices, and PrinciplesSome Cool Design Patterns, Practices, and Principles
Some Cool Design Patterns, Practices, and Principlesitsarsalan
 

Similar to Adapter design-pattern2015 (20)

Building API's
Building API'sBuilding API's
Building API's
 
GoF Design patterns I: Introduction + Structural Patterns
GoF Design patterns I:   Introduction + Structural PatternsGoF Design patterns I:   Introduction + Structural Patterns
GoF Design patterns I: Introduction + Structural Patterns
 
Design pattern in an expressive language java script
Design pattern in an expressive language java scriptDesign pattern in an expressive language java script
Design pattern in an expressive language java script
 
Contributing to Drupal
Contributing to DrupalContributing to Drupal
Contributing to Drupal
 
Design Patterns - General Introduction
Design Patterns - General IntroductionDesign Patterns - General Introduction
Design Patterns - General Introduction
 
Become a better UX designer through code
Become a better UX designer through codeBecome a better UX designer through code
Become a better UX designer through code
 
Ps02 cint24 mvc in php
Ps02 cint24 mvc in phpPs02 cint24 mvc in php
Ps02 cint24 mvc in php
 
Software Development with PHP & Laravel
Software Development  with PHP & LaravelSoftware Development  with PHP & Laravel
Software Development with PHP & Laravel
 
Design patterns
Design patternsDesign patterns
Design patterns
 
The Why and What of Pattern Lab
The Why and What of Pattern LabThe Why and What of Pattern Lab
The Why and What of Pattern Lab
 
30 Skills to Master to Become a Senior Software Engineer
30 Skills to Master to Become a Senior Software Engineer30 Skills to Master to Become a Senior Software Engineer
30 Skills to Master to Become a Senior Software Engineer
 
Vipul divyanshu mahout_documentation
Vipul divyanshu mahout_documentationVipul divyanshu mahout_documentation
Vipul divyanshu mahout_documentation
 
Drupal Aware Design: Good Techniques for Better Themes
Drupal Aware Design: Good Techniques for Better ThemesDrupal Aware Design: Good Techniques for Better Themes
Drupal Aware Design: Good Techniques for Better Themes
 
ContainerDayVietnam2016: Become a Cloud-native Developer
ContainerDayVietnam2016: Become a Cloud-native DeveloperContainerDayVietnam2016: Become a Cloud-native Developer
ContainerDayVietnam2016: Become a Cloud-native Developer
 
The Drupal 7 Worst Practices Catalogue
The Drupal 7 Worst Practices CatalogueThe Drupal 7 Worst Practices Catalogue
The Drupal 7 Worst Practices Catalogue
 
Open agile is free and open source community agile-
Open agile  is free and open source community agile-Open agile  is free and open source community agile-
Open agile is free and open source community agile-
 
Presentation 1 Web--dev
Presentation 1 Web--devPresentation 1 Web--dev
Presentation 1 Web--dev
 
Making the Most of Modern PHP in Drupal 7
Making the Most of Modern PHP in Drupal 7Making the Most of Modern PHP in Drupal 7
Making the Most of Modern PHP in Drupal 7
 
Contributing to drupal
Contributing to drupalContributing to drupal
Contributing to drupal
 
Some Cool Design Patterns, Practices, and Principles
Some Cool Design Patterns, Practices, and PrinciplesSome Cool Design Patterns, Practices, and Principles
Some Cool Design Patterns, Practices, and Principles
 

Recently uploaded

call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Hararemasabamasaba
 

Recently uploaded (20)

call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 

Adapter design-pattern2015

  • 1. Object Oriented Programming Design Patterns The Adapter Pattern An example of Object Oriented PHP Implementation for < https://www.drupal.org/project/oop_design_patterns >
  • 2. OOP Design Patterns Links Drupal.org: VicOnt, nafes Presentation Code: https://www.drupal.org/project/oop_design_patterns https://www.drupal.org/project/oop_examples < https://www.drupal.org/project/oop_design_patterns >
  • 3. OOP Design Patterns: The Gang of Four! It all started around 1994 when a group of 4 IBM programmers: Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides based on their coding experience , were able to observe and document a set of about 23 common problems and their best accepted solutions < https://www.drupal.org/project/oop_design_patterns >
  • 4. OOP Design Patterns What are design patterns? Recurring solutions to common software development challenges < https://www.drupal.org/project/oop_design_patterns > O
  • 5. OOP Design Patterns Some common software development challenges: ➢ Building new applications while leveraging existing codebases ➢ Building/enhancing applications securely, quickly and effectively ➢ Integrating new and existing applications ➢ Multiple developers programming the same product ➢ Few developers programming many products ➢ Varying, sometimes unknown, data sources, OS, Setups < https://www.drupal.org/project/oop_design_patterns >
  • 6. OOP Design Patterns What are design patterns not? a) They are not the end to all of your coding challenges. b) They are not a requirement of object oriented programming. c) They are not a substitute for application code and logic. d) They are not always the best solution for the job. e) They are not always the easiest concept to grasp and/or use. < https://www.drupal.org/project/oop_design_patterns > b) DDT DRY DOT OnceAndOnlyOnce KISS/YAGNI PARETO Don’t Do Twice Don’t Repeat Yourself Do One Thing Each and every declaration of behavior should appear Once (For) You ain't gonna need it 80effort/20functionality normalization in the RelationalModel and removing redundancies 80%of code is crap Programmers’ Code, Rule #27, Rules are best broken by those who have mastered them
  • 7. OOP Design Patterns GOF Classification for patterns Creational What: deal with object creation mechanisms How: somehow controlling the object creation Example: Abstract Factory Create a series of related objects without specifying their distinct classes. Usually all classes implements the same interface. < https://www.drupal.org/project/oop_design_patterns > Structural What: ease/simplify the design How: by identifying a simple way to realize relationships between entities. Example: Adapter/Wrapper Translate one interface for a class into a compatible interface –by providing it’s interface to clients while using the original interface. Behavioral What: identify common communication patterns between objects How: realizing these patterns Example: Template Method A skeleton of an algorithm, well-suited for framework libraries. The user implements one method and the superclass do the job.
  • 8. OOP Design Patterns The Adapter Pattern Purpose: allows the interface of an existing class to be used from another interface. It is often used to make existing classes work with others without modifying their source code. Examples where Adapter Pattern may help: • I want to add search capabilities to my application and support multiple search engines such as Google, Yahoo, Bing… • Have an image loader for different kinds of images JPG, GIF, PNG… • Use different Email providers: Gmail, Hotmail, YahooMail… • Use different data sources: Db, XML, TXT, CSV… • Connect to different Db: MySQL, PostgreSQL, MSSQL, Oracle • Have multiple downloads using different protocols: HTTP, HTTPS, FTP… • Use different payment providers: Moneris, AuthorizeNet, Skrill… < https://www.drupal.org/project/oop_design_patterns >
  • 9. OOP Design Patterns If Client and Adaptee are incompatible, we may create a new class called Adapter, and place it in between Target and Adaptee. Components become compatible with each other through Adapter. As long as some component integrates incompatible interfaces, it can be considered an adapter. < https://www.drupal.org/project/oop_design_patterns > Usually Adaptee class implements the Target interface. Client and Adaptee are compatible!
  • 10. OOP Design Patterns PHP Adapter: When you've opened a can of worms, then the only way to seal them again - Is using a bigger jar < https://www.drupal.org/project/oop_design_patterns > The Interface Incompatible classes
  • 11. OOP Design Patterns Design patterns are a great way to modularize your code and create reusable structures. But they mean nothing if they go unused. Go code something. < https://www.drupal.org/project/oop_design_patterns >
  • 12. OOP Design Patterns The Problem: multiple Payment Providers < https://www.drupal.org/project/oop_design_patterns >
  • 13. OOP Design Patterns The Solution: Adapter/Wrapper for Providers 1, 3 < https://www.drupal.org/project/oop_design_patterns > Scope res op
  • 14. OOP Design Patterns The Solution: Adapter/Wrapper for Provider 2 < https://www.drupal.org/project/oop_design_patterns >
  • 15. OOP Design Patterns Adapter Pattern: UML diagram, programming to the interface < https://www.drupal.org/project/oop_design_patterns >
  • 16. OOP Design Patterns Adapter Pattern: Easy of use, programming to the interface
  • 17. OOP Design Patterns Adapter Pattern: Drupal 7 implementation < https://www.drupal.org/project/oop_design_patterns >
  • 18. OOP Design Patterns Adapter Pattern: Drupal 8 implementation < https://www.drupal.org/project/oop_design_patterns >
  • 19. OOP Design Patterns CodeCase in action: < https://www.drupal.org/project/oop_design_patterns >
  • 20. OOP Design Patterns CodeCase in action: < https://www.drupal.org/project/oop_design_patterns >
  • 21. OOP Design Patterns To be Continued... Controller (GenRespAsignSoftPatt), Facade (GOF) ➢ Probably one of the most common patterns in OOP ➢ One of the most powerful patterns in development ➢ Opens a wealth of new possibilities, when understood ➢ Very flexible when favoring composition over inheritance ➢ Encapsulates what changes to allow for greater extendability < https://www.drupal.org/project/oop_design_patterns >
  • 22. OOP Design Patterns Acknowledgments Donquixote (Andreas Hennings) For PHP Class loading suite (PSR-4) https://www.drupal.org/project/xautoload Nafes (Nik Alexandrov) For Starting OOP examples in Drupal https://www.drupal.org/project/oop_examples < https://www.drupal.org/project/oop_design_patterns >