SlideShare ist ein Scribd-Unternehmen logo
Wie der CosmoShop mit generischen
Hookpoints in Perl-Objekten „umspringt“
How the CosmoShop handles
generic Hook Points in Perl Objects
Product
Development
• new features
• security updates
• most recent third party packages
• adapted frame conditions (EU regulations)
• more modern source code
• state-of-the-art design
Timeline
of
The
Windows
Versions
Reservations
About
Updates
• technical risk: never change a running system
• usability improvements: changed interfaces cause confusion
• new mechanics: changed workflows to get used to
• state-of-the-art design: looks "different"
•incompatible custom changes
Outsource
to
Plugins
• modularity by hooks
• compatibility for many release versions
• reusability for multiple installations
Custom Changes in Plugins
Classic
Manual
Hook
Points
dedicated hook points at the beginning
and end of a function
sub myFunction {
&hook_before_myFunction(@_);
my $result = […]
&hook_after_myFunction($result, @_);
}
BUT:
Can you hook into
a function call
dynamically?
$AUTOLOAD
1st
Try
package MyObject;
our $AUTOLOAD;
sub AUTOLOAD {
return &myFunction() + 2;
}
sub myFunction {
return 1;
}
print &myFunction(); ## result: 1
AUTOLOAD won't
be executed as the
called function
already exists
2nd
Try
package MyObject;
our $AUTOLOAD;
sub AUTOLOAD {
my $function = $AUTOLOAD;
$function =~ s/^(.*)::(.+?)$/$2/sg;
my $hookableFunction = 'hookable_'.$function;
return &$hookableFunction() + 2;
}
sub hookable_myFunction {
return 1;
}
print &myFunction(); ## result: 3
AUTOLOAD is executed
as the current function
doesn't exist!
BUT:
unpleasant prefix
in the function name
Object
to
Hook
package My::Object;
sub myFunction {
my $self = shift;
return $self->myOtherFunction();
}
sub myOtherFunction {
[…]
}
1;
Our
Solution:
Twins
!
dummy object in original namespace actual object in the twin namespace Core
package My::Object;
use base My::HookBase;
1;
package My::Core::Object;
use base My::BaseObject;
sub myFunction {
my $self = shift;
return $self->{hookclass}->myOtherFunction();
}
sub myOtherFunction {
[…]
}
1;
here
comes
the
Hip-Hop
$myObject->myFunction()
My::Core::Object
sub myFunction {
my $self = shift;
return $self->{hookclass}-
>myOtherFunction();
}
sub myOtherFunction {
[…]
}
My::Object
AUTOLOAD Dummy
$Hooks->addCoreHook({
coreObject => 'My::Object',
coreFunction => 'myFunction',
runlevel => 100,
hookFunction => sub {
my $self = shift;
my $hookQueue = shift;
my @param = @_;
## code before: can manipulate @param
my $result = $self->nextHook($hookQueue, @param);
## code afterwards: can manipulate $result
return $result;
}
});
in
the
plugin:
sub addCoreHook {
my $self = shift;
my $param = shift;
my $coreObject = $param->{coreObject};
my $coreFunction = $param->{coreFunction};
push @{$self->{coreHooks}->{$coreObject}->{$coreFunction}}, {
hookFunction => $param->{hookFunction},
runlevel => $param->{runlevel},
};
}
sub getCoreHooks {
my $self = shift;
my $coreObject = shift;
my $coreFunction = shift;
return {
hookFunctions => $self->sortByRunlevel($self->{coreHooks}->{$coreObject}->{$coreFunction}),
coreFunction => $coreFunction,
};
}
in
Hooks.pm
package My::HookBase;
sub new {
my $class = shift;
my $params = shift;
my $self = {};
bless ($self, $class);
my $coreClass = $class;
$coreClass =~ s/^My::/My::Core::/sg;
my $corePath = $coreClass;
$corePath =~ s/::///sg;
require $corePath.'.pm';
$params->{hookclass} = $self;
$self->{corebase} = $coreClass->new($params);
return $self;
}
our $AUTOLOAD;
sub AUTOLOAD {
my $self = shift;
my $function = $AUTOLOAD;
$function =~ s/^(.*)::(.+?)$/$2/sg;
my $package = $1;
return $self->parseHooks($package, $function, @_);
}
in
the
dummy
object:
sub parseHooks {
my $self = shift;
my $package = shift;
my $function = shift;
my @param = @_;
my $hookQueue = $self->getCoreHooks($package, $function);
return $self->nextHook($hookQueue, @param);
}
sub nextHook {
my $self = shift;
my $hookQueue = shift;
my @params = @_;
my $hookFunctions = $hookQueue->{hookFunctions}; ## sorted list of hooks
if (my $thisHook = shift @$hookFunctions) { ## one hook after another
my $hookFunction = $thisHook->{hookFunction};
return &$hookFunction($self, $hookQueue, @param); ## run the hook function
} else {
my $coreFunction = $hookQueue->{coreFunction}; ## function to hook
return $self->{corebase}->$coreFunction(@param); ## run the base function
}
}
in the plugin:
$Hooks->addCoreHook({
coreObject => 'My::Object',
coreFunction => 'myFunction',
runlevel => 100,
hookFunction => sub {
my $self = shift;
my $hookQueue = shift;
my @param = @_;
## code before: can manipulate @param
my $result = $self->nextHook($hookQueue, @param);
## code afterwards: can manipulate $result
return $result;
}
});
in
the
dummy
object:
How do we get the
hook system in existing
software installations?
With patience !
The hook system has already
been implemented in the year
2014
and all current CosmoShop
installations
have it ready to use

Weitere ähnliche Inhalte

Kürzlich hochgeladen

Search Result Showing My Post is Now Buried
Search Result Showing My Post is Now BuriedSearch Result Showing My Post is Now Buried
Search Result Showing My Post is Now Buried
Trish Parr
 
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
3ipehhoa
 
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC
 
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
3ipehhoa
 
Explore-Insanony: Watch Instagram Stories Secretly
Explore-Insanony: Watch Instagram Stories SecretlyExplore-Insanony: Watch Instagram Stories Secretly
Explore-Insanony: Watch Instagram Stories Secretly
Trending Blogers
 
假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理
假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理
假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理
cuobya
 
manuaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaal
manuaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalmanuaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaal
manuaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaal
wolfsoftcompanyco
 
Ready to Unlock the Power of Blockchain!
Ready to Unlock the Power of Blockchain!Ready to Unlock the Power of Blockchain!
Ready to Unlock the Power of Blockchain!
Toptal Tech
 
不能毕业如何获得(USYD毕业证)悉尼大学毕业证成绩单一比一原版制作
不能毕业如何获得(USYD毕业证)悉尼大学毕业证成绩单一比一原版制作不能毕业如何获得(USYD毕业证)悉尼大学毕业证成绩单一比一原版制作
不能毕业如何获得(USYD毕业证)悉尼大学毕业证成绩单一比一原版制作
bseovas
 
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
eutxy
 
重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理
重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理
重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理
vmemo1
 
Italy Agriculture Equipment Market Outlook to 2027
Italy Agriculture Equipment Market Outlook to 2027Italy Agriculture Equipment Market Outlook to 2027
Italy Agriculture Equipment Market Outlook to 2027
harveenkaur52
 
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptxBridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Brad Spiegel Macon GA
 
学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作
学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作
学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作
zyfovom
 
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
3ipehhoa
 
国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理
国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理
国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理
zoowe
 
存档可查的(USC毕业证)南加利福尼亚大学毕业证成绩单制做办理
存档可查的(USC毕业证)南加利福尼亚大学毕业证成绩单制做办理存档可查的(USC毕业证)南加利福尼亚大学毕业证成绩单制做办理
存档可查的(USC毕业证)南加利福尼亚大学毕业证成绩单制做办理
fovkoyb
 
制作毕业证书(ANU毕业证)莫纳什大学毕业证成绩单官方原版办理
制作毕业证书(ANU毕业证)莫纳什大学毕业证成绩单官方原版办理制作毕业证书(ANU毕业证)莫纳什大学毕业证成绩单官方原版办理
制作毕业证书(ANU毕业证)莫纳什大学毕业证成绩单官方原版办理
cuobya
 
成绩单ps(UST毕业证)圣托马斯大学毕业证成绩单快速办理
成绩单ps(UST毕业证)圣托马斯大学毕业证成绩单快速办理成绩单ps(UST毕业证)圣托马斯大学毕业证成绩单快速办理
成绩单ps(UST毕业证)圣托马斯大学毕业证成绩单快速办理
ysasp1
 
Understanding User Behavior with Google Analytics.pdf
Understanding User Behavior with Google Analytics.pdfUnderstanding User Behavior with Google Analytics.pdf
Understanding User Behavior with Google Analytics.pdf
SEO Article Boost
 

Kürzlich hochgeladen (20)

Search Result Showing My Post is Now Buried
Search Result Showing My Post is Now BuriedSearch Result Showing My Post is Now Buried
Search Result Showing My Post is Now Buried
 
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
 
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
 
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
 
Explore-Insanony: Watch Instagram Stories Secretly
Explore-Insanony: Watch Instagram Stories SecretlyExplore-Insanony: Watch Instagram Stories Secretly
Explore-Insanony: Watch Instagram Stories Secretly
 
假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理
假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理
假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理
 
manuaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaal
manuaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalmanuaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaal
manuaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaal
 
Ready to Unlock the Power of Blockchain!
Ready to Unlock the Power of Blockchain!Ready to Unlock the Power of Blockchain!
Ready to Unlock the Power of Blockchain!
 
不能毕业如何获得(USYD毕业证)悉尼大学毕业证成绩单一比一原版制作
不能毕业如何获得(USYD毕业证)悉尼大学毕业证成绩单一比一原版制作不能毕业如何获得(USYD毕业证)悉尼大学毕业证成绩单一比一原版制作
不能毕业如何获得(USYD毕业证)悉尼大学毕业证成绩单一比一原版制作
 
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
 
重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理
重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理
重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理
 
Italy Agriculture Equipment Market Outlook to 2027
Italy Agriculture Equipment Market Outlook to 2027Italy Agriculture Equipment Market Outlook to 2027
Italy Agriculture Equipment Market Outlook to 2027
 
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptxBridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
 
学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作
学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作
学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作
 
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
 
国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理
国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理
国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理
 
存档可查的(USC毕业证)南加利福尼亚大学毕业证成绩单制做办理
存档可查的(USC毕业证)南加利福尼亚大学毕业证成绩单制做办理存档可查的(USC毕业证)南加利福尼亚大学毕业证成绩单制做办理
存档可查的(USC毕业证)南加利福尼亚大学毕业证成绩单制做办理
 
制作毕业证书(ANU毕业证)莫纳什大学毕业证成绩单官方原版办理
制作毕业证书(ANU毕业证)莫纳什大学毕业证成绩单官方原版办理制作毕业证书(ANU毕业证)莫纳什大学毕业证成绩单官方原版办理
制作毕业证书(ANU毕业证)莫纳什大学毕业证成绩单官方原版办理
 
成绩单ps(UST毕业证)圣托马斯大学毕业证成绩单快速办理
成绩单ps(UST毕业证)圣托马斯大学毕业证成绩单快速办理成绩单ps(UST毕业证)圣托马斯大学毕业证成绩单快速办理
成绩单ps(UST毕业证)圣托马斯大学毕业证成绩单快速办理
 
Understanding User Behavior with Google Analytics.pdf
Understanding User Behavior with Google Analytics.pdfUnderstanding User Behavior with Google Analytics.pdf
Understanding User Behavior with Google Analytics.pdf
 

Empfohlen

Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Christy Abraham Joy
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
MindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
GetSmarter
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
Alireza Esmikhani
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
Project for Public Spaces & National Center for Biking and Walking
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
Erica Santiago
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Saba Software
 

Empfohlen (20)

Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
 

Hip-Hop-Hooks_english_v2_16-04-2024.pptx

  • 1. Wie der CosmoShop mit generischen Hookpoints in Perl-Objekten „umspringt“ How the CosmoShop handles generic Hook Points in Perl Objects
  • 2. Product Development • new features • security updates • most recent third party packages • adapted frame conditions (EU regulations) • more modern source code • state-of-the-art design
  • 4. Reservations About Updates • technical risk: never change a running system • usability improvements: changed interfaces cause confusion • new mechanics: changed workflows to get used to • state-of-the-art design: looks "different" •incompatible custom changes
  • 5. Outsource to Plugins • modularity by hooks • compatibility for many release versions • reusability for multiple installations Custom Changes in Plugins
  • 6. Classic Manual Hook Points dedicated hook points at the beginning and end of a function sub myFunction { &hook_before_myFunction(@_); my $result = […] &hook_after_myFunction($result, @_); }
  • 7. BUT: Can you hook into a function call dynamically?
  • 9. 1st Try package MyObject; our $AUTOLOAD; sub AUTOLOAD { return &myFunction() + 2; } sub myFunction { return 1; } print &myFunction(); ## result: 1 AUTOLOAD won't be executed as the called function already exists
  • 10. 2nd Try package MyObject; our $AUTOLOAD; sub AUTOLOAD { my $function = $AUTOLOAD; $function =~ s/^(.*)::(.+?)$/$2/sg; my $hookableFunction = 'hookable_'.$function; return &$hookableFunction() + 2; } sub hookable_myFunction { return 1; } print &myFunction(); ## result: 3 AUTOLOAD is executed as the current function doesn't exist! BUT: unpleasant prefix in the function name
  • 11. Object to Hook package My::Object; sub myFunction { my $self = shift; return $self->myOtherFunction(); } sub myOtherFunction { […] } 1;
  • 12. Our Solution: Twins ! dummy object in original namespace actual object in the twin namespace Core package My::Object; use base My::HookBase; 1; package My::Core::Object; use base My::BaseObject; sub myFunction { my $self = shift; return $self->{hookclass}->myOtherFunction(); } sub myOtherFunction { […] } 1;
  • 13. here comes the Hip-Hop $myObject->myFunction() My::Core::Object sub myFunction { my $self = shift; return $self->{hookclass}- >myOtherFunction(); } sub myOtherFunction { […] } My::Object AUTOLOAD Dummy
  • 14. $Hooks->addCoreHook({ coreObject => 'My::Object', coreFunction => 'myFunction', runlevel => 100, hookFunction => sub { my $self = shift; my $hookQueue = shift; my @param = @_; ## code before: can manipulate @param my $result = $self->nextHook($hookQueue, @param); ## code afterwards: can manipulate $result return $result; } }); in the plugin:
  • 15. sub addCoreHook { my $self = shift; my $param = shift; my $coreObject = $param->{coreObject}; my $coreFunction = $param->{coreFunction}; push @{$self->{coreHooks}->{$coreObject}->{$coreFunction}}, { hookFunction => $param->{hookFunction}, runlevel => $param->{runlevel}, }; } sub getCoreHooks { my $self = shift; my $coreObject = shift; my $coreFunction = shift; return { hookFunctions => $self->sortByRunlevel($self->{coreHooks}->{$coreObject}->{$coreFunction}), coreFunction => $coreFunction, }; } in Hooks.pm
  • 16. package My::HookBase; sub new { my $class = shift; my $params = shift; my $self = {}; bless ($self, $class); my $coreClass = $class; $coreClass =~ s/^My::/My::Core::/sg; my $corePath = $coreClass; $corePath =~ s/::///sg; require $corePath.'.pm'; $params->{hookclass} = $self; $self->{corebase} = $coreClass->new($params); return $self; } our $AUTOLOAD; sub AUTOLOAD { my $self = shift; my $function = $AUTOLOAD; $function =~ s/^(.*)::(.+?)$/$2/sg; my $package = $1; return $self->parseHooks($package, $function, @_); } in the dummy object:
  • 17. sub parseHooks { my $self = shift; my $package = shift; my $function = shift; my @param = @_; my $hookQueue = $self->getCoreHooks($package, $function); return $self->nextHook($hookQueue, @param); } sub nextHook { my $self = shift; my $hookQueue = shift; my @params = @_; my $hookFunctions = $hookQueue->{hookFunctions}; ## sorted list of hooks if (my $thisHook = shift @$hookFunctions) { ## one hook after another my $hookFunction = $thisHook->{hookFunction}; return &$hookFunction($self, $hookQueue, @param); ## run the hook function } else { my $coreFunction = $hookQueue->{coreFunction}; ## function to hook return $self->{corebase}->$coreFunction(@param); ## run the base function } } in the plugin: $Hooks->addCoreHook({ coreObject => 'My::Object', coreFunction => 'myFunction', runlevel => 100, hookFunction => sub { my $self = shift; my $hookQueue = shift; my @param = @_; ## code before: can manipulate @param my $result = $self->nextHook($hookQueue, @param); ## code afterwards: can manipulate $result return $result; } }); in the dummy object:
  • 18. How do we get the hook system in existing software installations?
  • 19. With patience ! The hook system has already been implemented in the year 2014 and all current CosmoShop installations have it ready to use