SlideShare uma empresa Scribd logo
1 de 18
Perl Design Patterns
             brian d foy
   Stonehenge Consulting Ser vices
         February 24, 2006
     Grand Rapids Perl Mongers



               Sponsored by PriorityHealth
Patterns aren’t a ...
code cookbook
module on CPAN
methodology
goal
religion
Patterns are a ...
abstraction for things we need to do
solutions for common problems
name for a design element
common language for design discussions
way to apply a common design to code
relationships
Three parts

Context
System of forces
Solution
Nothing’s Free

Actions have reactions
Complexity turns up somewhere else
Choices have consequences
Who’s responsible?

Our application needs config information
But we have several modules
Who loads the data?
How do the other modules get it?
A pattern

Load the configuration from anywhere
But load it only one time
Anyone else gets a reference to it
The order doesn’t matter
What’s in a name

A couple words instead of sentences
We agree on what the name implies
Others know what we mean
“A rose is a rose is a rose”
The Singleton
There is only one configuration
Let’s call it a singleton
... or a highlander
We don’t have an implementation
Just a name with implied design elements
An implementation
package My::Config;

my $singleton = undef;

sub new {
   my $class = shift;

  return $singleton if defined $singleton;

  $singleton = bless {}, $class;
  }
A use
package My::Database;
use My::Config;

my $config = My::Config->new( ... );

package My::Network;
use My::Config;

my $config = My::Config->new( ... );
That isn’t the only way

 The pattern is not a prescription
 It’s an option
 Maybe another pattern works better.
A Meta Class
   Write a meta class that contains all of
   the object parts
   Objects talk to the meta class to
   communicate with the other parts
use My::Controller;

my $controller = My::Controller->new(...);

my $value = $controller->config->get( ... );
Delegates
package My::Controller;

sub new {
   my $class = shift;

   my $self = bless {}, $class;

   # weaken some of these circular refs
   @$self{ qw(_config _database _network ) } = (
      My::Config->new( controller => $self ),
      DBI->new( ... ),
      My::Socket->new( controller => $self ),
      );

   $self;
   }

sub config { $_[0]{_config} }
Some Perl Modules

Apache::DBI
Netscape::Bookmarks
CGI::Prototype
many things in Class::*, almost
Beware

Patterns are not code
No matter what the Gang of Four say
Class::* is code
Ergo, ...
Perl is Better

People like Patterns because they get code
C++, Java suck at some things (Iterators)
Perl doesn’t suck at the same things
Further Reading
The Perl Review (lots of articles (by me))
“Design Patterns Aren’t” by Mark Jason
Dominus
 http:/
      /perl.plover.com/yak/design/

Design Patterns - Erich Gamma, et al.
(Gang of Four)
Perl Design Patterns Wiki
 http:/
      /perldesignpatterns.com/

Mais conteúdo relacionado

Mais procurados

Basic Concepts Of OOPS/OOPS in Java,C++
Basic Concepts Of OOPS/OOPS in Java,C++Basic Concepts Of OOPS/OOPS in Java,C++
Basic Concepts Of OOPS/OOPS in Java,C++Guneesh Basundhra
 
Oop features java presentationshow
Oop features java presentationshowOop features java presentationshow
Oop features java presentationshowilias ahmed
 
learn Ruby in AMC Square learning
learn Ruby in AMC Square learninglearn Ruby in AMC Square learning
learn Ruby in AMC Square learningASIT Education
 
object oriented programing lecture 1
object oriented programing lecture 1object oriented programing lecture 1
object oriented programing lecture 1Geophery sanga
 
Clean code lecture part I
Clean code lecture part IClean code lecture part I
Clean code lecture part IJun Shimizu
 
Building an NLP DNN in 5 Minutes
Building an NLP DNN in 5 MinutesBuilding an NLP DNN in 5 Minutes
Building an NLP DNN in 5 MinutesJenny Midwinter
 
2CPP09 - Encapsulation
2CPP09 - Encapsulation2CPP09 - Encapsulation
2CPP09 - EncapsulationMichael Heron
 
encapsulation, inheritance, overriding, overloading
encapsulation, inheritance, overriding, overloadingencapsulation, inheritance, overriding, overloading
encapsulation, inheritance, overriding, overloadingShivam Singhal
 
CPP14 - Encapsulation
CPP14 - EncapsulationCPP14 - Encapsulation
CPP14 - EncapsulationMichael Heron
 
Object oriented programming concept- Saurabh Upadhyay
Object oriented programming concept- Saurabh UpadhyayObject oriented programming concept- Saurabh Upadhyay
Object oriented programming concept- Saurabh UpadhyaySaurabh Upadhyay
 
Oops presentation java
Oops presentation javaOops presentation java
Oops presentation javaJayasankarPR2
 
JAVA Data Types - Part 1
JAVA Data Types - Part 1JAVA Data Types - Part 1
JAVA Data Types - Part 1Ashok Asn
 

Mais procurados (20)

Oops
OopsOops
Oops
 
Basic Concepts Of OOPS/OOPS in Java,C++
Basic Concepts Of OOPS/OOPS in Java,C++Basic Concepts Of OOPS/OOPS in Java,C++
Basic Concepts Of OOPS/OOPS in Java,C++
 
Oop features java presentationshow
Oop features java presentationshowOop features java presentationshow
Oop features java presentationshow
 
javaopps concepts
javaopps conceptsjavaopps concepts
javaopps concepts
 
Characteristics of oop
Characteristics of oopCharacteristics of oop
Characteristics of oop
 
learn Ruby in AMC Square learning
learn Ruby in AMC Square learninglearn Ruby in AMC Square learning
learn Ruby in AMC Square learning
 
object oriented programing lecture 1
object oriented programing lecture 1object oriented programing lecture 1
object oriented programing lecture 1
 
Encapsulation
EncapsulationEncapsulation
Encapsulation
 
Clean code lecture part I
Clean code lecture part IClean code lecture part I
Clean code lecture part I
 
Building an NLP DNN in 5 Minutes
Building an NLP DNN in 5 MinutesBuilding an NLP DNN in 5 Minutes
Building an NLP DNN in 5 Minutes
 
2CPP09 - Encapsulation
2CPP09 - Encapsulation2CPP09 - Encapsulation
2CPP09 - Encapsulation
 
encapsulation
encapsulationencapsulation
encapsulation
 
encapsulation, inheritance, overriding, overloading
encapsulation, inheritance, overriding, overloadingencapsulation, inheritance, overriding, overloading
encapsulation, inheritance, overriding, overloading
 
Oop concepts
Oop conceptsOop concepts
Oop concepts
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
CPP14 - Encapsulation
CPP14 - EncapsulationCPP14 - Encapsulation
CPP14 - Encapsulation
 
Object oriented programming concept- Saurabh Upadhyay
Object oriented programming concept- Saurabh UpadhyayObject oriented programming concept- Saurabh Upadhyay
Object oriented programming concept- Saurabh Upadhyay
 
Encapsulation
EncapsulationEncapsulation
Encapsulation
 
Oops presentation java
Oops presentation javaOops presentation java
Oops presentation java
 
JAVA Data Types - Part 1
JAVA Data Types - Part 1JAVA Data Types - Part 1
JAVA Data Types - Part 1
 

Destaque

Stellar - Monitor Case Study
Stellar - Monitor Case StudyStellar - Monitor Case Study
Stellar - Monitor Case StudyBrittany Hadfield
 
Service design & BE London 2016
Service design & BE London 2016Service design & BE London 2016
Service design & BE London 2016Luis Arnal
 
función de un plan de negocios
 función de un plan de negocios función de un plan de negocios
función de un plan de negociosLuis Camacho
 
TOPOLOGIAS DE RED
TOPOLOGIAS DE RED TOPOLOGIAS DE RED
TOPOLOGIAS DE RED fer-1399
 
Capability Document Experiential Recursive Simulation
Capability Document Experiential  Recursive SimulationCapability Document Experiential  Recursive Simulation
Capability Document Experiential Recursive Simulationkarthikeyan j
 
PO 397 Intro Political Machines
PO 397 Intro Political Machines PO 397 Intro Political Machines
PO 397 Intro Political Machines atrantham
 
Campaigns and Elections
Campaigns and ElectionsCampaigns and Elections
Campaigns and Electionsatrantham
 
Las 10 carreras más estudiadas vs las 10 más demandadas por las empresas (1)
Las 10 carreras más estudiadas vs las 10 más demandadas por las empresas (1)Las 10 carreras más estudiadas vs las 10 más demandadas por las empresas (1)
Las 10 carreras más estudiadas vs las 10 más demandadas por las empresas (1)fernanda lopez
 
Pruebas de aislamiento motores baja tension
Pruebas de aislamiento motores baja tensionPruebas de aislamiento motores baja tension
Pruebas de aislamiento motores baja tensionGustavo De Haro
 
Module 1 lesson 4 identifying proportional relationships
Module 1 lesson 4 identifying proportional relationshipsModule 1 lesson 4 identifying proportional relationships
Module 1 lesson 4 identifying proportional relationshipsErik Tjersland
 
Project Management with Kanban 2.0
Project Management with Kanban 2.0Project Management with Kanban 2.0
Project Management with Kanban 2.0Planview
 
Why Marketing and IT Will Love the New DNN
Why Marketing and IT Will Love the New DNNWhy Marketing and IT Will Love the New DNN
Why Marketing and IT Will Love the New DNNDNN
 

Destaque (17)

Stellar - Monitor Case Study
Stellar - Monitor Case StudyStellar - Monitor Case Study
Stellar - Monitor Case Study
 
PO 101 Constitution
PO 101 ConstitutionPO 101 Constitution
PO 101 Constitution
 
Emprendedor
EmprendedorEmprendedor
Emprendedor
 
Service design & BE London 2016
Service design & BE London 2016Service design & BE London 2016
Service design & BE London 2016
 
función de un plan de negocios
 función de un plan de negocios función de un plan de negocios
función de un plan de negocios
 
TOPOLOGIAS DE RED
TOPOLOGIAS DE RED TOPOLOGIAS DE RED
TOPOLOGIAS DE RED
 
Capability Document Experiential Recursive Simulation
Capability Document Experiential  Recursive SimulationCapability Document Experiential  Recursive Simulation
Capability Document Experiential Recursive Simulation
 
PO 397 Intro Political Machines
PO 397 Intro Political Machines PO 397 Intro Political Machines
PO 397 Intro Political Machines
 
Campaigns and Elections
Campaigns and ElectionsCampaigns and Elections
Campaigns and Elections
 
CSC ADS Brochure
CSC ADS BrochureCSC ADS Brochure
CSC ADS Brochure
 
Las 10 carreras más estudiadas vs las 10 más demandadas por las empresas (1)
Las 10 carreras más estudiadas vs las 10 más demandadas por las empresas (1)Las 10 carreras más estudiadas vs las 10 más demandadas por las empresas (1)
Las 10 carreras más estudiadas vs las 10 más demandadas por las empresas (1)
 
Tombolo
TomboloTombolo
Tombolo
 
Pruebas de aislamiento motores baja tension
Pruebas de aislamiento motores baja tensionPruebas de aislamiento motores baja tension
Pruebas de aislamiento motores baja tension
 
Module 1 lesson 4 identifying proportional relationships
Module 1 lesson 4 identifying proportional relationshipsModule 1 lesson 4 identifying proportional relationships
Module 1 lesson 4 identifying proportional relationships
 
Ppt manajemen pendidikan kelompok 1 fiks
Ppt manajemen pendidikan kelompok 1 fiksPpt manajemen pendidikan kelompok 1 fiks
Ppt manajemen pendidikan kelompok 1 fiks
 
Project Management with Kanban 2.0
Project Management with Kanban 2.0Project Management with Kanban 2.0
Project Management with Kanban 2.0
 
Why Marketing and IT Will Love the New DNN
Why Marketing and IT Will Love the New DNNWhy Marketing and IT Will Love the New DNN
Why Marketing and IT Will Love the New DNN
 

Semelhante a Design Patterns in Perl (Grand Rapids Perl Mongers, 2006)

JAVA-PPT'S.pptx
JAVA-PPT'S.pptxJAVA-PPT'S.pptx
JAVA-PPT'S.pptxRaazIndia
 
JAVA-PPT'S-complete-chrome.pptx
JAVA-PPT'S-complete-chrome.pptxJAVA-PPT'S-complete-chrome.pptx
JAVA-PPT'S-complete-chrome.pptxKunalYadav65140
 
Oops concepts in php
Oops concepts in phpOops concepts in php
Oops concepts in phpCPD INDIA
 
Top 100-php-interview-questions-and-answers-are-below-120816023558-phpapp01
Top 100-php-interview-questions-and-answers-are-below-120816023558-phpapp01Top 100-php-interview-questions-and-answers-are-below-120816023558-phpapp01
Top 100-php-interview-questions-and-answers-are-below-120816023558-phpapp01Tekblink Jeeten
 
Object-Oriented Programming.pptx
Object-Oriented Programming.pptxObject-Oriented Programming.pptx
Object-Oriented Programming.pptxssusereae59d
 
Introduction to Ecmascript - ES6
Introduction to Ecmascript - ES6Introduction to Ecmascript - ES6
Introduction to Ecmascript - ES6Nilesh Jayanandana
 
OOP, Networking, Linux/Unix
OOP, Networking, Linux/UnixOOP, Networking, Linux/Unix
OOP, Networking, Linux/UnixNovita Sari
 
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...Sagar Verma
 
Making Django and NoSQL Play Nice
Making Django and NoSQL Play NiceMaking Django and NoSQL Play Nice
Making Django and NoSQL Play NiceAlex Gaynor
 
Fnt Software Solutions Pvt Ltd Placement Papers - PHP Technology
Fnt Software Solutions Pvt Ltd Placement Papers - PHP TechnologyFnt Software Solutions Pvt Ltd Placement Papers - PHP Technology
Fnt Software Solutions Pvt Ltd Placement Papers - PHP Technologyfntsofttech
 
Class 7 - PHP Object Oriented Programming
Class 7 - PHP Object Oriented ProgrammingClass 7 - PHP Object Oriented Programming
Class 7 - PHP Object Oriented ProgrammingAhmed Swilam
 
C# coding standards, good programming principles & refactoring
C# coding standards, good programming principles & refactoringC# coding standards, good programming principles & refactoring
C# coding standards, good programming principles & refactoringEyob Lube
 

Semelhante a Design Patterns in Perl (Grand Rapids Perl Mongers, 2006) (20)

JAVA-PPT'S.pptx
JAVA-PPT'S.pptxJAVA-PPT'S.pptx
JAVA-PPT'S.pptx
 
JAVA-PPT'S-complete-chrome.pptx
JAVA-PPT'S-complete-chrome.pptxJAVA-PPT'S-complete-chrome.pptx
JAVA-PPT'S-complete-chrome.pptx
 
JAVA-PPT'S.pdf
JAVA-PPT'S.pdfJAVA-PPT'S.pdf
JAVA-PPT'S.pdf
 
Adventures in TclOO
Adventures in TclOOAdventures in TclOO
Adventures in TclOO
 
Oops concepts in php
Oops concepts in phpOops concepts in php
Oops concepts in php
 
Top 100-php-interview-questions-and-answers-are-below-120816023558-phpapp01
Top 100-php-interview-questions-and-answers-are-below-120816023558-phpapp01Top 100-php-interview-questions-and-answers-are-below-120816023558-phpapp01
Top 100-php-interview-questions-and-answers-are-below-120816023558-phpapp01
 
L03 Software Design
L03 Software DesignL03 Software Design
L03 Software Design
 
Object-Oriented Programming.pptx
Object-Oriented Programming.pptxObject-Oriented Programming.pptx
Object-Oriented Programming.pptx
 
Introduction to Ecmascript - ES6
Introduction to Ecmascript - ES6Introduction to Ecmascript - ES6
Introduction to Ecmascript - ES6
 
OOP, Networking, Linux/Unix
OOP, Networking, Linux/UnixOOP, Networking, Linux/Unix
OOP, Networking, Linux/Unix
 
C# interview
C# interviewC# interview
C# interview
 
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
 
Making Django and NoSQL Play Nice
Making Django and NoSQL Play NiceMaking Django and NoSQL Play Nice
Making Django and NoSQL Play Nice
 
Value Objects
Value ObjectsValue Objects
Value Objects
 
Advance oops concepts
Advance oops conceptsAdvance oops concepts
Advance oops concepts
 
Fnt Software Solutions Pvt Ltd Placement Papers - PHP Technology
Fnt Software Solutions Pvt Ltd Placement Papers - PHP TechnologyFnt Software Solutions Pvt Ltd Placement Papers - PHP Technology
Fnt Software Solutions Pvt Ltd Placement Papers - PHP Technology
 
Class 7 - PHP Object Oriented Programming
Class 7 - PHP Object Oriented ProgrammingClass 7 - PHP Object Oriented Programming
Class 7 - PHP Object Oriented Programming
 
Warehousing
WarehousingWarehousing
Warehousing
 
C# coding standards, good programming principles & refactoring
C# coding standards, good programming principles & refactoringC# coding standards, good programming principles & refactoring
C# coding standards, good programming principles & refactoring
 
Only oop
Only oopOnly oop
Only oop
 

Mais de brian d foy

Conferences for Beginners presentation
Conferences for Beginners presentationConferences for Beginners presentation
Conferences for Beginners presentationbrian d foy
 
20 years in Perl
20 years in Perl20 years in Perl
20 years in Perlbrian d foy
 
PrettyDump Perl 6 (London.pm)
PrettyDump Perl 6 (London.pm)PrettyDump Perl 6 (London.pm)
PrettyDump Perl 6 (London.pm)brian d foy
 
Dumping Perl 6 (French Perl Workshop)
Dumping Perl 6 (French Perl Workshop)Dumping Perl 6 (French Perl Workshop)
Dumping Perl 6 (French Perl Workshop)brian d foy
 
Perl v5.26 Features (AmsterdamX.pm)
Perl v5.26 Features (AmsterdamX.pm)Perl v5.26 Features (AmsterdamX.pm)
Perl v5.26 Features (AmsterdamX.pm)brian d foy
 
Dumping Perl 6 (AmsterdamX.pm)
Dumping Perl 6 (AmsterdamX.pm)Dumping Perl 6 (AmsterdamX.pm)
Dumping Perl 6 (AmsterdamX.pm)brian d foy
 
6 more things about Perl 6
6 more things about Perl 66 more things about Perl 6
6 more things about Perl 6brian d foy
 
6 things about perl 6
6 things about perl 66 things about perl 6
6 things about perl 6brian d foy
 
Perl 5.28 new features
Perl 5.28 new featuresPerl 5.28 new features
Perl 5.28 new featuresbrian d foy
 
The Surprisingly Tense History of the Schwartzian Transform
The Surprisingly Tense History of the Schwartzian TransformThe Surprisingly Tense History of the Schwartzian Transform
The Surprisingly Tense History of the Schwartzian Transformbrian d foy
 
Perl Power Tools - Saint Perl 6
Perl Power Tools - Saint Perl 6Perl Power Tools - Saint Perl 6
Perl Power Tools - Saint Perl 6brian d foy
 
Perl Bag of Tricks - Baltimore Perl mongers
Perl Bag of Tricks  -  Baltimore Perl mongersPerl Bag of Tricks  -  Baltimore Perl mongers
Perl Bag of Tricks - Baltimore Perl mongersbrian d foy
 
The Whitespace in the Perl Community
The Whitespace in the Perl CommunityThe Whitespace in the Perl Community
The Whitespace in the Perl Communitybrian d foy
 
CPAN Workshop, Chicago 2014
CPAN Workshop, Chicago 2014CPAN Workshop, Chicago 2014
CPAN Workshop, Chicago 2014brian d foy
 
Parsing JSON with a single regex
Parsing JSON with a single regexParsing JSON with a single regex
Parsing JSON with a single regexbrian d foy
 
Reverse Installing CPAN
Reverse Installing CPANReverse Installing CPAN
Reverse Installing CPANbrian d foy
 
Advanced modulinos
Advanced modulinosAdvanced modulinos
Advanced modulinosbrian d foy
 
Advanced modulinos trial
Advanced modulinos trialAdvanced modulinos trial
Advanced modulinos trialbrian d foy
 

Mais de brian d foy (20)

Conferences for Beginners presentation
Conferences for Beginners presentationConferences for Beginners presentation
Conferences for Beginners presentation
 
20 years in Perl
20 years in Perl20 years in Perl
20 years in Perl
 
PrettyDump Perl 6 (London.pm)
PrettyDump Perl 6 (London.pm)PrettyDump Perl 6 (London.pm)
PrettyDump Perl 6 (London.pm)
 
Dumping Perl 6 (French Perl Workshop)
Dumping Perl 6 (French Perl Workshop)Dumping Perl 6 (French Perl Workshop)
Dumping Perl 6 (French Perl Workshop)
 
Perl v5.26 Features (AmsterdamX.pm)
Perl v5.26 Features (AmsterdamX.pm)Perl v5.26 Features (AmsterdamX.pm)
Perl v5.26 Features (AmsterdamX.pm)
 
Dumping Perl 6 (AmsterdamX.pm)
Dumping Perl 6 (AmsterdamX.pm)Dumping Perl 6 (AmsterdamX.pm)
Dumping Perl 6 (AmsterdamX.pm)
 
6 more things about Perl 6
6 more things about Perl 66 more things about Perl 6
6 more things about Perl 6
 
6 things about perl 6
6 things about perl 66 things about perl 6
6 things about perl 6
 
Perl 5.28 new features
Perl 5.28 new featuresPerl 5.28 new features
Perl 5.28 new features
 
The Surprisingly Tense History of the Schwartzian Transform
The Surprisingly Tense History of the Schwartzian TransformThe Surprisingly Tense History of the Schwartzian Transform
The Surprisingly Tense History of the Schwartzian Transform
 
Perl Power Tools - Saint Perl 6
Perl Power Tools - Saint Perl 6Perl Power Tools - Saint Perl 6
Perl Power Tools - Saint Perl 6
 
Perl Bag of Tricks - Baltimore Perl mongers
Perl Bag of Tricks  -  Baltimore Perl mongersPerl Bag of Tricks  -  Baltimore Perl mongers
Perl Bag of Tricks - Baltimore Perl mongers
 
The Whitespace in the Perl Community
The Whitespace in the Perl CommunityThe Whitespace in the Perl Community
The Whitespace in the Perl Community
 
CPAN Workshop, Chicago 2014
CPAN Workshop, Chicago 2014CPAN Workshop, Chicago 2014
CPAN Workshop, Chicago 2014
 
Parsing JSON with a single regex
Parsing JSON with a single regexParsing JSON with a single regex
Parsing JSON with a single regex
 
Reverse Installing CPAN
Reverse Installing CPANReverse Installing CPAN
Reverse Installing CPAN
 
Advanced modulinos
Advanced modulinosAdvanced modulinos
Advanced modulinos
 
Advanced modulinos trial
Advanced modulinos trialAdvanced modulinos trial
Advanced modulinos trial
 
Bag of tricks
Bag of tricksBag of tricks
Bag of tricks
 
I ❤ CPAN
I ❤ CPANI ❤ CPAN
I ❤ CPAN
 

Último

Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 

Último (20)

Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 

Design Patterns in Perl (Grand Rapids Perl Mongers, 2006)

  • 1. Perl Design Patterns brian d foy Stonehenge Consulting Ser vices February 24, 2006 Grand Rapids Perl Mongers Sponsored by PriorityHealth
  • 2. Patterns aren’t a ... code cookbook module on CPAN methodology goal religion
  • 3. Patterns are a ... abstraction for things we need to do solutions for common problems name for a design element common language for design discussions way to apply a common design to code relationships
  • 5. Nothing’s Free Actions have reactions Complexity turns up somewhere else Choices have consequences
  • 6. Who’s responsible? Our application needs config information But we have several modules Who loads the data? How do the other modules get it?
  • 7. A pattern Load the configuration from anywhere But load it only one time Anyone else gets a reference to it The order doesn’t matter
  • 8. What’s in a name A couple words instead of sentences We agree on what the name implies Others know what we mean “A rose is a rose is a rose”
  • 9. The Singleton There is only one configuration Let’s call it a singleton ... or a highlander We don’t have an implementation Just a name with implied design elements
  • 10. An implementation package My::Config; my $singleton = undef; sub new { my $class = shift; return $singleton if defined $singleton; $singleton = bless {}, $class; }
  • 11. A use package My::Database; use My::Config; my $config = My::Config->new( ... ); package My::Network; use My::Config; my $config = My::Config->new( ... );
  • 12. That isn’t the only way The pattern is not a prescription It’s an option Maybe another pattern works better.
  • 13. A Meta Class Write a meta class that contains all of the object parts Objects talk to the meta class to communicate with the other parts use My::Controller; my $controller = My::Controller->new(...); my $value = $controller->config->get( ... );
  • 14. Delegates package My::Controller; sub new { my $class = shift; my $self = bless {}, $class; # weaken some of these circular refs @$self{ qw(_config _database _network ) } = ( My::Config->new( controller => $self ), DBI->new( ... ), My::Socket->new( controller => $self ), ); $self; } sub config { $_[0]{_config} }
  • 16. Beware Patterns are not code No matter what the Gang of Four say Class::* is code Ergo, ...
  • 17. Perl is Better People like Patterns because they get code C++, Java suck at some things (Iterators) Perl doesn’t suck at the same things
  • 18. Further Reading The Perl Review (lots of articles (by me)) “Design Patterns Aren’t” by Mark Jason Dominus http:/ /perl.plover.com/yak/design/ Design Patterns - Erich Gamma, et al. (Gang of Four) Perl Design Patterns Wiki http:/ /perldesignpatterns.com/