SlideShare ist ein Scribd-Unternehmen logo
1 von 24
Downloaden Sie, um offline zu lesen
Objects of Desire
A Few Questions (and Answers) on
Modern Object-Oriented Development




                       Kevlin Henney
                       kevlin@curbralan.com
Agenda

• Intent
    Some answers concerning OO and related topics
• Content
    A brief history of objects
    Linguistics
    Encapsulation
    Class hierarchies
    Patterns
    Testing

                                       PHP Conference 2007   2
A Brief History of Objects

History rarely happens in the right order or at the right time, but the job of aa
 History rarely happens in the right order or at the right time, but the job of
historian is to make it appear as if it did.
 historian is to make it appear as if it did.
                                                                    James Burke
                                                                     James Burke




                                                               PHP Conference 2007   3
Back to the Future

• How old is OO?
    40 years old this year (Simula 67, Norway, 1967)
• When did OO become mainstream?
    Around the mid 1990s (1997 is often quoted)
• Where is OO used?
    Everywhere... and then some
• What about the future?
    Objects will remain mainstream, but they are not
    the only game in town
                                          PHP Conference 2007   4
Linguistics

Language is not simply aareporting device for experience but aadefining
 Language is not simply reporting device for experience but defining
framework for it.
 framework for it.
                                                             Benjamin Whorf
                                                              Benjamin Whorf




                                                           PHP Conference 2007   5
General Linguistics

• Is there a relationship between language and
  OO style?
    In spite of rumours to the contrary, there is a strong
    relationship between language features and
    appropriate OO style
• What can we learn from other languages?
    A lot!
• Which is the best OO language?
    It depends

                                            PHP Conference 2007   6
Type Systems

• How do static and dynamic type systems
  compare?
    They each both strengths and weaknesses
• How does PHP5's type system measure up?
    It is inherently dynamic, so some of the features
    borrowed from static type systems are surprising
• What about type hints?
    These appear to combine all the problems of static
    typing with all the weaknesses of dynamic typing

                                          PHP Conference 2007   7
Encapsulation

encapsulate enclose (something) in or as if in aacapsule.
 encapsulate enclose (something) in or as if in capsule.
       express the essential feature of (someone or something) succinctly.
        express the essential feature of (someone or something) succinctly.
       enclose (a message or signal) in aaset of codes which allow use by or
        enclose (a message or signal) in set of codes which allow use by or
       transfer through different computer systems or networks.
        transfer through different computer systems or networks.
       provide an interface for (a piece of software or hardware) to allow or
        provide an interface for (a piece of software or hardware) to allow or
       simplify access for the user.
        simplify access for the user.
                                    The New Oxford Dictionary of English
                                    The New Oxford Dictionary of English




                                                                 PHP Conference 2007   8
In a Capsule

• How do you use public, protected and private?
    Declare data private, steer clear of protected, and only
    make methods public if you know why and where
    you're going to use them and how to test them
• So, encapsulation is about data privacy?
    No, it relates to stability, coherence and ease of use
    of an object — data privacy is a by-product
• How big should a class be?
    Big enough, but not too big

                                             PHP Conference 2007   9
Train Wrecks and Vampires

• Is chaining calls on function results useful?
    PHP4's model was, quite frankly, surprising
• What's the Law of Demeter?
    Don't talk to strangers
• What's a train wreck?
    A violation of the Law of Demeter
• But what about collections?
    Return iterators and offer focused methods, rather
    than uncontrolled access to private collections
                                          PHP Conference 2007   10
Class Hierarchies

The history of all hitherto existing society is the history of class struggles.
 The history of all hitherto existing society is the history of class struggles.
                                                Karl Marx and Friedrich Engels
                                                 Karl Marx and Friedrich Engels




                                                              PHP Conference 2007   11
Substitutability

• What is LSP?
    The Liskov Substitution Principle
• What is the Liskov Substitution Principle?
    Organise class hierarchies according to type
    substitutability, not according to commonality of
    implementation
• What about reuse of implementation?
    Favour delegation, steer clear of ad hoc subclassing
    — spaghetti inheritance is hard to digest

                                           PHP Conference 2007   12
Interfaces

• What is the common role of interfaces?
    In statically typed languages, the interface construct,
    or equivalent, promotes polymorphism and reduces
    dependencies — inheritance of implementation is
    the strongest form of coupling in an OO system
    In dynamically typed languages, the notion of
    usage type is normally left as an informal protocol
    or is expressed as predicate or constraint on objects
• What is the role of interfaces in PHP5?
    Good question
                                            PHP Conference 2007   13
Patterns

The enormous success of design patterns is aatestimonial to the commonality
 The enormous success of design patterns is testimonial to the commonality
seen by object programmers. The success of the book Design Patterns, however,
 seen by object programmers. The success of the book Design Patterns, however,
has stifled any diversity in expressing these patterns.
 has stifled any diversity in expressing these patterns.
                                                                    Kent Beck
                                                                    Kent Beck




                                                             PHP Conference 2007   14
Shameless Plug




                 PHP Conference 2007   15
Pitter Pattern Brain Drop

• What is a pattern?
    A good pattern captures a proven solution practice
    along with the problem it addresses and the context
    in which it applies
• Are patterns only about OO design?
    No
• How do you apply patterns?
    Unconsciously and tacitly or consciously and
    explicitly — but watch out for patternitis

                                          PHP Conference 2007   16
The Good, the Bad and the Ugly

• What are the top five patterns to know?
    It depends
• If dependencies are so bad, why is Decorator
  recommended?
    They are, and it isn't: it was documented as an OO
    pattern nearly 15 years ago, but Interceptor is now
    considered better for much of what Decorator does
• Do patterns make code more complicated?
    Only if used to make code more complicated

                                          PHP Conference 2007   17
The Epicycle Problem

• What is the trouble with Singleton?
    It is normally used by coincidence, it introduces a
    centralised point of coupling, it complicates testing
    and it comes with various lifecycle problems
• What are the alternatives?
    Focus on making essential object relationships
    explicit, e.g. using patterns like Context Object
• What about the Monostate pattern?
    This is also known as the Borg pattern, which tells
    you everything you need to know
                                            PHP Conference 2007   18
Testing

Science is what we have learned about how to keep from fooling ourselves.
 Science is what we have learned about how to keep from fooling ourselves.
                                                            Richard Feynman
                                                             Richard Feynman




                                                           PHP Conference 2007   19
Motivation for Testing




                         PHP Conference 2007   20
More Motivation




                  PHP Conference 2007   21
And More




           PHP Conference 2007   22
Testing, Testing, One, Two, One, Two

• How soon should testing be introduced?
    Either as soon as you know what to test — why
    wait? — or as soon as you don't know what to test
    — use testing to help drive detailed design and
    clarification of requirements
• What is the relationship between testing and
  design?
    A test is a proposition about how something is
    used, so it can be used as a form of specification and
    clarification of needs and knowledge
                                            PHP Conference 2007   23
In Closing...

The only thing to do with good advice is to pass it on. It is never any use to oneself.
 The only thing to do with good advice is to pass it on. It is never any use to oneself.
                                                                        Oscar Wilde
                                                                         Oscar Wilde




                                                                  PHP Conference 2007      24

Weitere ähnliche Inhalte

Ähnlich wie DPC2007 Objects Of Desire (Kevlin Henney)

ExperOPS5: A Rule-based, Data-driven Production System Language Puts a Mind b...
ExperOPS5: A Rule-based, Data-driven Production System Language Puts a Mind b...ExperOPS5: A Rule-based, Data-driven Production System Language Puts a Mind b...
ExperOPS5: A Rule-based, Data-driven Production System Language Puts a Mind b...Jim Salmons
 
Gadgets pwn us? A pattern language for CALL
Gadgets pwn us? A pattern language for CALLGadgets pwn us? A pattern language for CALL
Gadgets pwn us? A pattern language for CALLLawrie Hunter
 
Inheritance Versus Roles - The In-Depth Version
Inheritance Versus Roles - The In-Depth VersionInheritance Versus Roles - The In-Depth Version
Inheritance Versus Roles - The In-Depth VersionCurtis Poe
 
Scientific presentatation skills.pptx
Scientific presentatation skills.pptxScientific presentatation skills.pptx
Scientific presentatation skills.pptxobedcudjoe1
 
Deep Learning, an interactive introduction for NLP-ers
Deep Learning, an interactive introduction for NLP-ersDeep Learning, an interactive introduction for NLP-ers
Deep Learning, an interactive introduction for NLP-ersRoelof Pieters
 
Multi-modal Neural Machine Translation - Iacer Calixto
Multi-modal Neural Machine Translation - Iacer CalixtoMulti-modal Neural Machine Translation - Iacer Calixto
Multi-modal Neural Machine Translation - Iacer CalixtoSebastian Ruder
 
W4A 2012 - Vagner Santana
W4A 2012 - Vagner SantanaW4A 2012 - Vagner Santana
W4A 2012 - Vagner SantanaVagner Santana
 
The Four Principles Of Object Oriented Programming
The Four Principles Of Object Oriented ProgrammingThe Four Principles Of Object Oriented Programming
The Four Principles Of Object Oriented ProgrammingDiane Allen
 
Reflective Plan Examples
Reflective Plan ExamplesReflective Plan Examples
Reflective Plan ExamplesMonica Turner
 
Storytelling for research software engineers
Storytelling for research software engineersStorytelling for research software engineers
Storytelling for research software engineersAlbanLevy
 
Deploying php applications
Deploying php applicationsDeploying php applications
Deploying php applicationsNiklas Modess
 
Using ICT to Analyse Language
Using ICT to Analyse LanguageUsing ICT to Analyse Language
Using ICT to Analyse LanguageEka Nathiqo
 
Applying software design principles in practice
Applying software design principles in practiceApplying software design principles in practice
Applying software design principles in practiceGanesh Samarthyam
 
Dynamic Languages In The Enterprise (4developers march 2009)
Dynamic Languages In The Enterprise (4developers march 2009)Dynamic Languages In The Enterprise (4developers march 2009)
Dynamic Languages In The Enterprise (4developers march 2009)Ivo Jansch
 
Thomas Wolf "An Introduction to Transfer Learning and Hugging Face"
Thomas Wolf "An Introduction to Transfer Learning and Hugging Face"Thomas Wolf "An Introduction to Transfer Learning and Hugging Face"
Thomas Wolf "An Introduction to Transfer Learning and Hugging Face"Fwdays
 
Equipes ágeis em 2012 - Lições aprendidas
Equipes ágeis em 2012 - Lições aprendidasEquipes ágeis em 2012 - Lições aprendidas
Equipes ágeis em 2012 - Lições aprendidasGuilherme Silveira
 
Four Patterns at the Heart of Good Programming Style
Four Patterns at the Heart of Good Programming StyleFour Patterns at the Heart of Good Programming Style
Four Patterns at the Heart of Good Programming StylePhilip Schwarz
 

Ähnlich wie DPC2007 Objects Of Desire (Kevlin Henney) (20)

oops.pdf
oops.pdfoops.pdf
oops.pdf
 
Extreme programming
Extreme programmingExtreme programming
Extreme programming
 
ExperOPS5: A Rule-based, Data-driven Production System Language Puts a Mind b...
ExperOPS5: A Rule-based, Data-driven Production System Language Puts a Mind b...ExperOPS5: A Rule-based, Data-driven Production System Language Puts a Mind b...
ExperOPS5: A Rule-based, Data-driven Production System Language Puts a Mind b...
 
Gadgets pwn us? A pattern language for CALL
Gadgets pwn us? A pattern language for CALLGadgets pwn us? A pattern language for CALL
Gadgets pwn us? A pattern language for CALL
 
Inheritance Versus Roles - The In-Depth Version
Inheritance Versus Roles - The In-Depth VersionInheritance Versus Roles - The In-Depth Version
Inheritance Versus Roles - The In-Depth Version
 
Scientific presentatation skills.pptx
Scientific presentatation skills.pptxScientific presentatation skills.pptx
Scientific presentatation skills.pptx
 
Deep Learning, an interactive introduction for NLP-ers
Deep Learning, an interactive introduction for NLP-ersDeep Learning, an interactive introduction for NLP-ers
Deep Learning, an interactive introduction for NLP-ers
 
Multi-modal Neural Machine Translation - Iacer Calixto
Multi-modal Neural Machine Translation - Iacer CalixtoMulti-modal Neural Machine Translation - Iacer Calixto
Multi-modal Neural Machine Translation - Iacer Calixto
 
W4A 2012 - Vagner Santana
W4A 2012 - Vagner SantanaW4A 2012 - Vagner Santana
W4A 2012 - Vagner Santana
 
groovy & grails - lecture 1
groovy & grails - lecture 1groovy & grails - lecture 1
groovy & grails - lecture 1
 
The Four Principles Of Object Oriented Programming
The Four Principles Of Object Oriented ProgrammingThe Four Principles Of Object Oriented Programming
The Four Principles Of Object Oriented Programming
 
Reflective Plan Examples
Reflective Plan ExamplesReflective Plan Examples
Reflective Plan Examples
 
Storytelling for research software engineers
Storytelling for research software engineersStorytelling for research software engineers
Storytelling for research software engineers
 
Deploying php applications
Deploying php applicationsDeploying php applications
Deploying php applications
 
Using ICT to Analyse Language
Using ICT to Analyse LanguageUsing ICT to Analyse Language
Using ICT to Analyse Language
 
Applying software design principles in practice
Applying software design principles in practiceApplying software design principles in practice
Applying software design principles in practice
 
Dynamic Languages In The Enterprise (4developers march 2009)
Dynamic Languages In The Enterprise (4developers march 2009)Dynamic Languages In The Enterprise (4developers march 2009)
Dynamic Languages In The Enterprise (4developers march 2009)
 
Thomas Wolf "An Introduction to Transfer Learning and Hugging Face"
Thomas Wolf "An Introduction to Transfer Learning and Hugging Face"Thomas Wolf "An Introduction to Transfer Learning and Hugging Face"
Thomas Wolf "An Introduction to Transfer Learning and Hugging Face"
 
Equipes ágeis em 2012 - Lições aprendidas
Equipes ágeis em 2012 - Lições aprendidasEquipes ágeis em 2012 - Lições aprendidas
Equipes ágeis em 2012 - Lições aprendidas
 
Four Patterns at the Heart of Good Programming Style
Four Patterns at the Heart of Good Programming StyleFour Patterns at the Heart of Good Programming Style
Four Patterns at the Heart of Good Programming Style
 

Mehr von dpc

ezComponents - Derick Rethans
ezComponents - Derick RethansezComponents - Derick Rethans
ezComponents - Derick Rethansdpc
 
Software And The Taste Of Mayo - Marco Tabini
Software And The Taste Of Mayo - Marco TabiniSoftware And The Taste Of Mayo - Marco Tabini
Software And The Taste Of Mayo - Marco Tabinidpc
 
Deployment With Subversion - Lorna Mitchell
Deployment With Subversion - Lorna MitchellDeployment With Subversion - Lorna Mitchell
Deployment With Subversion - Lorna Mitchelldpc
 
Best Practices with Zend Framework - Matthew Weier O'Phinney
Best Practices with Zend Framework - Matthew Weier O'PhinneyBest Practices with Zend Framework - Matthew Weier O'Phinney
Best Practices with Zend Framework - Matthew Weier O'Phinneydpc
 
State Of PHP - Zeev Suraski
State Of PHP - Zeev SuraskiState Of PHP - Zeev Suraski
State Of PHP - Zeev Suraskidpc
 
Symfony 1.1 - Fabien Potencier
Symfony 1.1 - Fabien PotencierSymfony 1.1 - Fabien Potencier
Symfony 1.1 - Fabien Potencierdpc
 
Advanced PHP: Design Patterns - Dennis-Jan Broerse
Advanced PHP: Design Patterns - Dennis-Jan BroerseAdvanced PHP: Design Patterns - Dennis-Jan Broerse
Advanced PHP: Design Patterns - Dennis-Jan Broersedpc
 
New Features PHPUnit 3.3 - Sebastian Bergmann
New Features PHPUnit 3.3 - Sebastian BergmannNew Features PHPUnit 3.3 - Sebastian Bergmann
New Features PHPUnit 3.3 - Sebastian Bergmanndpc
 
PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch
PHP 5.3 and PHP 6; a look ahead - Stefan PriebschPHP 5.3 and PHP 6; a look ahead - Stefan Priebsch
PHP 5.3 and PHP 6; a look ahead - Stefan Priebschdpc
 
Quality Assurance in PHP projects - Sebastian Bergmann
Quality Assurance in PHP projects - Sebastian BergmannQuality Assurance in PHP projects - Sebastian Bergmann
Quality Assurance in PHP projects - Sebastian Bergmanndpc
 
An Infrastructure for Team Development - Gaylord Aulke
An Infrastructure for Team Development - Gaylord AulkeAn Infrastructure for Team Development - Gaylord Aulke
An Infrastructure for Team Development - Gaylord Aulkedpc
 
Enterprise PHP Development - Ivo Jansch
Enterprise PHP Development - Ivo JanschEnterprise PHP Development - Ivo Jansch
Enterprise PHP Development - Ivo Janschdpc
 
DPC2008 Intro - Ivo Jansch
DPC2008 Intro - Ivo JanschDPC2008 Intro - Ivo Jansch
DPC2008 Intro - Ivo Janschdpc
 
DPC 2007 My First Mashup (Cal Evans)
DPC 2007 My First Mashup (Cal Evans)DPC 2007 My First Mashup (Cal Evans)
DPC 2007 My First Mashup (Cal Evans)dpc
 
DPC2007 CodeGear, Delphi For PHP (Pawel Glowacki)
DPC2007 CodeGear, Delphi For PHP (Pawel Glowacki)DPC2007 CodeGear, Delphi For PHP (Pawel Glowacki)
DPC2007 CodeGear, Delphi For PHP (Pawel Glowacki)dpc
 
DPC2007 Zend Framework (Gaylord Aulke)
DPC2007 Zend Framework (Gaylord Aulke)DPC2007 Zend Framework (Gaylord Aulke)
DPC2007 Zend Framework (Gaylord Aulke)dpc
 
DPC2007 Symfony (Stefan Koopmanschap)
DPC2007 Symfony (Stefan Koopmanschap)DPC2007 Symfony (Stefan Koopmanschap)
DPC2007 Symfony (Stefan Koopmanschap)dpc
 
DPC2007 PHP And Oracle (Kuassi Mensah)
DPC2007 PHP And Oracle (Kuassi Mensah)DPC2007 PHP And Oracle (Kuassi Mensah)
DPC2007 PHP And Oracle (Kuassi Mensah)dpc
 
DPC2007 Case Study Surfnet (Herman Van Dompseler)
DPC2007 Case Study Surfnet (Herman Van Dompseler)DPC2007 Case Study Surfnet (Herman Van Dompseler)
DPC2007 Case Study Surfnet (Herman Van Dompseler)dpc
 
DPC2007 Case Study Zoom & Webwereld (Sander vd Graaf)
DPC2007 Case Study Zoom & Webwereld (Sander vd Graaf)DPC2007 Case Study Zoom & Webwereld (Sander vd Graaf)
DPC2007 Case Study Zoom & Webwereld (Sander vd Graaf)dpc
 

Mehr von dpc (20)

ezComponents - Derick Rethans
ezComponents - Derick RethansezComponents - Derick Rethans
ezComponents - Derick Rethans
 
Software And The Taste Of Mayo - Marco Tabini
Software And The Taste Of Mayo - Marco TabiniSoftware And The Taste Of Mayo - Marco Tabini
Software And The Taste Of Mayo - Marco Tabini
 
Deployment With Subversion - Lorna Mitchell
Deployment With Subversion - Lorna MitchellDeployment With Subversion - Lorna Mitchell
Deployment With Subversion - Lorna Mitchell
 
Best Practices with Zend Framework - Matthew Weier O'Phinney
Best Practices with Zend Framework - Matthew Weier O'PhinneyBest Practices with Zend Framework - Matthew Weier O'Phinney
Best Practices with Zend Framework - Matthew Weier O'Phinney
 
State Of PHP - Zeev Suraski
State Of PHP - Zeev SuraskiState Of PHP - Zeev Suraski
State Of PHP - Zeev Suraski
 
Symfony 1.1 - Fabien Potencier
Symfony 1.1 - Fabien PotencierSymfony 1.1 - Fabien Potencier
Symfony 1.1 - Fabien Potencier
 
Advanced PHP: Design Patterns - Dennis-Jan Broerse
Advanced PHP: Design Patterns - Dennis-Jan BroerseAdvanced PHP: Design Patterns - Dennis-Jan Broerse
Advanced PHP: Design Patterns - Dennis-Jan Broerse
 
New Features PHPUnit 3.3 - Sebastian Bergmann
New Features PHPUnit 3.3 - Sebastian BergmannNew Features PHPUnit 3.3 - Sebastian Bergmann
New Features PHPUnit 3.3 - Sebastian Bergmann
 
PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch
PHP 5.3 and PHP 6; a look ahead - Stefan PriebschPHP 5.3 and PHP 6; a look ahead - Stefan Priebsch
PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch
 
Quality Assurance in PHP projects - Sebastian Bergmann
Quality Assurance in PHP projects - Sebastian BergmannQuality Assurance in PHP projects - Sebastian Bergmann
Quality Assurance in PHP projects - Sebastian Bergmann
 
An Infrastructure for Team Development - Gaylord Aulke
An Infrastructure for Team Development - Gaylord AulkeAn Infrastructure for Team Development - Gaylord Aulke
An Infrastructure for Team Development - Gaylord Aulke
 
Enterprise PHP Development - Ivo Jansch
Enterprise PHP Development - Ivo JanschEnterprise PHP Development - Ivo Jansch
Enterprise PHP Development - Ivo Jansch
 
DPC2008 Intro - Ivo Jansch
DPC2008 Intro - Ivo JanschDPC2008 Intro - Ivo Jansch
DPC2008 Intro - Ivo Jansch
 
DPC 2007 My First Mashup (Cal Evans)
DPC 2007 My First Mashup (Cal Evans)DPC 2007 My First Mashup (Cal Evans)
DPC 2007 My First Mashup (Cal Evans)
 
DPC2007 CodeGear, Delphi For PHP (Pawel Glowacki)
DPC2007 CodeGear, Delphi For PHP (Pawel Glowacki)DPC2007 CodeGear, Delphi For PHP (Pawel Glowacki)
DPC2007 CodeGear, Delphi For PHP (Pawel Glowacki)
 
DPC2007 Zend Framework (Gaylord Aulke)
DPC2007 Zend Framework (Gaylord Aulke)DPC2007 Zend Framework (Gaylord Aulke)
DPC2007 Zend Framework (Gaylord Aulke)
 
DPC2007 Symfony (Stefan Koopmanschap)
DPC2007 Symfony (Stefan Koopmanschap)DPC2007 Symfony (Stefan Koopmanschap)
DPC2007 Symfony (Stefan Koopmanschap)
 
DPC2007 PHP And Oracle (Kuassi Mensah)
DPC2007 PHP And Oracle (Kuassi Mensah)DPC2007 PHP And Oracle (Kuassi Mensah)
DPC2007 PHP And Oracle (Kuassi Mensah)
 
DPC2007 Case Study Surfnet (Herman Van Dompseler)
DPC2007 Case Study Surfnet (Herman Van Dompseler)DPC2007 Case Study Surfnet (Herman Van Dompseler)
DPC2007 Case Study Surfnet (Herman Van Dompseler)
 
DPC2007 Case Study Zoom & Webwereld (Sander vd Graaf)
DPC2007 Case Study Zoom & Webwereld (Sander vd Graaf)DPC2007 Case Study Zoom & Webwereld (Sander vd Graaf)
DPC2007 Case Study Zoom & Webwereld (Sander vd Graaf)
 

Kürzlich hochgeladen

New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
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
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
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
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
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
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
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
 
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
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
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
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 

Kürzlich hochgeladen (20)

New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
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)
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
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
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
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
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
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
 
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
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
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
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 

DPC2007 Objects Of Desire (Kevlin Henney)

  • 1. Objects of Desire A Few Questions (and Answers) on Modern Object-Oriented Development Kevlin Henney kevlin@curbralan.com
  • 2. Agenda • Intent Some answers concerning OO and related topics • Content A brief history of objects Linguistics Encapsulation Class hierarchies Patterns Testing PHP Conference 2007 2
  • 3. A Brief History of Objects History rarely happens in the right order or at the right time, but the job of aa History rarely happens in the right order or at the right time, but the job of historian is to make it appear as if it did. historian is to make it appear as if it did. James Burke James Burke PHP Conference 2007 3
  • 4. Back to the Future • How old is OO? 40 years old this year (Simula 67, Norway, 1967) • When did OO become mainstream? Around the mid 1990s (1997 is often quoted) • Where is OO used? Everywhere... and then some • What about the future? Objects will remain mainstream, but they are not the only game in town PHP Conference 2007 4
  • 5. Linguistics Language is not simply aareporting device for experience but aadefining Language is not simply reporting device for experience but defining framework for it. framework for it. Benjamin Whorf Benjamin Whorf PHP Conference 2007 5
  • 6. General Linguistics • Is there a relationship between language and OO style? In spite of rumours to the contrary, there is a strong relationship between language features and appropriate OO style • What can we learn from other languages? A lot! • Which is the best OO language? It depends PHP Conference 2007 6
  • 7. Type Systems • How do static and dynamic type systems compare? They each both strengths and weaknesses • How does PHP5's type system measure up? It is inherently dynamic, so some of the features borrowed from static type systems are surprising • What about type hints? These appear to combine all the problems of static typing with all the weaknesses of dynamic typing PHP Conference 2007 7
  • 8. Encapsulation encapsulate enclose (something) in or as if in aacapsule. encapsulate enclose (something) in or as if in capsule. express the essential feature of (someone or something) succinctly. express the essential feature of (someone or something) succinctly. enclose (a message or signal) in aaset of codes which allow use by or enclose (a message or signal) in set of codes which allow use by or transfer through different computer systems or networks. transfer through different computer systems or networks. provide an interface for (a piece of software or hardware) to allow or provide an interface for (a piece of software or hardware) to allow or simplify access for the user. simplify access for the user. The New Oxford Dictionary of English The New Oxford Dictionary of English PHP Conference 2007 8
  • 9. In a Capsule • How do you use public, protected and private? Declare data private, steer clear of protected, and only make methods public if you know why and where you're going to use them and how to test them • So, encapsulation is about data privacy? No, it relates to stability, coherence and ease of use of an object — data privacy is a by-product • How big should a class be? Big enough, but not too big PHP Conference 2007 9
  • 10. Train Wrecks and Vampires • Is chaining calls on function results useful? PHP4's model was, quite frankly, surprising • What's the Law of Demeter? Don't talk to strangers • What's a train wreck? A violation of the Law of Demeter • But what about collections? Return iterators and offer focused methods, rather than uncontrolled access to private collections PHP Conference 2007 10
  • 11. Class Hierarchies The history of all hitherto existing society is the history of class struggles. The history of all hitherto existing society is the history of class struggles. Karl Marx and Friedrich Engels Karl Marx and Friedrich Engels PHP Conference 2007 11
  • 12. Substitutability • What is LSP? The Liskov Substitution Principle • What is the Liskov Substitution Principle? Organise class hierarchies according to type substitutability, not according to commonality of implementation • What about reuse of implementation? Favour delegation, steer clear of ad hoc subclassing — spaghetti inheritance is hard to digest PHP Conference 2007 12
  • 13. Interfaces • What is the common role of interfaces? In statically typed languages, the interface construct, or equivalent, promotes polymorphism and reduces dependencies — inheritance of implementation is the strongest form of coupling in an OO system In dynamically typed languages, the notion of usage type is normally left as an informal protocol or is expressed as predicate or constraint on objects • What is the role of interfaces in PHP5? Good question PHP Conference 2007 13
  • 14. Patterns The enormous success of design patterns is aatestimonial to the commonality The enormous success of design patterns is testimonial to the commonality seen by object programmers. The success of the book Design Patterns, however, seen by object programmers. The success of the book Design Patterns, however, has stifled any diversity in expressing these patterns. has stifled any diversity in expressing these patterns. Kent Beck Kent Beck PHP Conference 2007 14
  • 15. Shameless Plug PHP Conference 2007 15
  • 16. Pitter Pattern Brain Drop • What is a pattern? A good pattern captures a proven solution practice along with the problem it addresses and the context in which it applies • Are patterns only about OO design? No • How do you apply patterns? Unconsciously and tacitly or consciously and explicitly — but watch out for patternitis PHP Conference 2007 16
  • 17. The Good, the Bad and the Ugly • What are the top five patterns to know? It depends • If dependencies are so bad, why is Decorator recommended? They are, and it isn't: it was documented as an OO pattern nearly 15 years ago, but Interceptor is now considered better for much of what Decorator does • Do patterns make code more complicated? Only if used to make code more complicated PHP Conference 2007 17
  • 18. The Epicycle Problem • What is the trouble with Singleton? It is normally used by coincidence, it introduces a centralised point of coupling, it complicates testing and it comes with various lifecycle problems • What are the alternatives? Focus on making essential object relationships explicit, e.g. using patterns like Context Object • What about the Monostate pattern? This is also known as the Borg pattern, which tells you everything you need to know PHP Conference 2007 18
  • 19. Testing Science is what we have learned about how to keep from fooling ourselves. Science is what we have learned about how to keep from fooling ourselves. Richard Feynman Richard Feynman PHP Conference 2007 19
  • 20. Motivation for Testing PHP Conference 2007 20
  • 21. More Motivation PHP Conference 2007 21
  • 22. And More PHP Conference 2007 22
  • 23. Testing, Testing, One, Two, One, Two • How soon should testing be introduced? Either as soon as you know what to test — why wait? — or as soon as you don't know what to test — use testing to help drive detailed design and clarification of requirements • What is the relationship between testing and design? A test is a proposition about how something is used, so it can be used as a form of specification and clarification of needs and knowledge PHP Conference 2007 23
  • 24. In Closing... The only thing to do with good advice is to pass it on. It is never any use to oneself. The only thing to do with good advice is to pass it on. It is never any use to oneself. Oscar Wilde Oscar Wilde PHP Conference 2007 24