SlideShare uma empresa Scribd logo
1 de 46
Baixar para ler offline
Orientação a Objetos
Princípios e Padrões
Quem sou eu?
‣ Programador no Glio
‣ Trabalhei na Dafiti, Emprego Ligado e Tripda
‣ Não mexo com PHP faz exatamente 1 ano
‣ Ruby
‣ @nelson_senna
Agenda
‣ Uma breve introdução a OOP
‣ Os primos pobres do S.O.L.I.D
‣ Padrões de projeto (GoF)
O que é Orientação a
Objetos?
O método é apoiado por
quatro pilares
Abstração
Abstração
Onde podemos errar?
“If a precondition is violated, this means
that a client has not satisfied its part of
the bargain, and hence the server
cannot proceed reliably. Similarly, if a
postcondition is violated, this means
that a server has not carried out its part
of the contract, and so its clients can no
longer trust the behavior of the server.”
Grady Booch
Encapsulamento
Encapsulamento
Onde podemos errar?
“No part of a complex system should
depend on the internal details of any
other part”
Ingalls, D.
Modularidade
Modularidade
Onde podemos errar?
“The overall goal of the decomposition
into modules is the reduction of
software cost by allowing modules to be
designed and revised independently....
Each module's structure should be
simple enough that it can be
understood fully;”
Britton and Parnas
Hierarquia
Hierarquia
Onde podemos errar?
“Inheritance makes it possible to define
new software in the same way we
introduce any concept to a newcomer,
by comparing it with something that is
already familiar”
Cox, B.
O que é um objeto?
Propriedades de um
objeto
‣ Estado
‣ Comportamento
‣ Identidade
“The state of an object encompasses all
of the (usually static) properties of the
object plus the current (usually dynamic)
values of each of these properties.”
Grady Booch
“The state of an object represents the
cumulative results of its behavior.”
Grady Booch
“Assim como átomos podem existir
repetidas vezes, a identidade possibilita
que múltiplas instâncias possam
coexistir.”
Um troxa aí
Objetos não são sacos
de dados!
Princípios
Least Astonishment
Command Query
Separation
Tell don’t ask
Law of Demeter
Padrões
Decorator
Strategy
Chain of Responsibility
Composite
Template Method
Facade
Dúvidas?
Avalie a palestra!
Lista de imagens
‣ Builders: https://flic.kr/p/mjweU
‣ Ikebana: https://flic.kr/p/6P7McX
‣ Boundary: https://flic.kr/p/3QrzLy
‣ Modularity: https://flic.kr/p/9sdBqQ
‣ Hierarchy: https://flic.kr/p/fgGtcP
‣ Objects: https://flic.kr/p/AD4FMh
Referências
‣ Tell don’t ask: https://pragprog.com/articles/tell-dont-ask
‣ OOP: Object-Oriented Analysis and Design with Applications - Grady Booch et
al
‣ Law of Demeter: http://www.ccs.neu.edu/research/demeter/demeter-
method/LawOfDemeter/paper-boy/demeter.pdf
‣ CQS: http://martinfowler.com/bliki/CommandQuerySeparation.html
‣ Least Astonishment: http://c2.com/cgi/wiki?PrincipleOfLeastAstonishment
‣ Design Patterns: Design Patterns: Elements of Reusable Object-Oriented
Software - Gamma et al
‣ Decorator: https://8thlight.com/blog/doug-bradbury/2016/07/18/not-a-
decorator-ruby.html
‣ Template Method: https://medium.com/ruby-on-rails/what-i-learned-from-
sandi-metz-9d0c94347b7f#.2y8u1prb4

Mais conteúdo relacionado

Semelhante a OOP: Princípios e Padroes

Design for Testability
Design for Testability Design for Testability
Design for Testability Pawel Kalbrun
 
Behavior-Driven Design: One Team's Exploration
Behavior-Driven Design: One Team's ExplorationBehavior-Driven Design: One Team's Exploration
Behavior-Driven Design: One Team's Explorationdtcoutu
 
Tdd2018 state of the software quality in Germany
Tdd2018 state of the software quality in GermanyTdd2018 state of the software quality in Germany
Tdd2018 state of the software quality in GermanyOrlovsky Consulting GbR
 
Mature agile teams essential patterns v4 - half day workshop
Mature agile teams   essential patterns v4 - half day workshopMature agile teams   essential patterns v4 - half day workshop
Mature agile teams essential patterns v4 - half day workshopdrewz lin
 
Pair Programming, TDD and other impractical things
Pair Programming, TDD and other impractical thingsPair Programming, TDD and other impractical things
Pair Programming, TDD and other impractical thingsMarcello Duarte
 
“Don’t Repeat Yourself”: 4 Process Street Features to Keep Work DRY
“Don’t Repeat Yourself”: 4 Process Street Features to Keep Work DRY“Don’t Repeat Yourself”: 4 Process Street Features to Keep Work DRY
“Don’t Repeat Yourself”: 4 Process Street Features to Keep Work DRYLizzyManz
 
Developing solid applications
Developing solid applicationsDeveloping solid applications
Developing solid applicationsNilesh Bangar
 
Visualizing Work: If you can't see it, you can't manage it
Visualizing Work: If you can't see it, you can't manage itVisualizing Work: If you can't see it, you can't manage it
Visualizing Work: If you can't see it, you can't manage itFernando Cuenca
 
15 Experts on the Art of JavaScript Programming
15 Experts on the Art of JavaScript Programming15 Experts on the Art of JavaScript Programming
15 Experts on the Art of JavaScript ProgrammingFusionCharts
 
Better and Faster: A Journey Toward Clean Code and Enjoyment
Better and Faster: A Journey Toward Clean Code and EnjoymentBetter and Faster: A Journey Toward Clean Code and Enjoyment
Better and Faster: A Journey Toward Clean Code and EnjoymentChris Holland
 
Design poo my_jug_en_ppt
Design poo my_jug_en_pptDesign poo my_jug_en_ppt
Design poo my_jug_en_pptagnes_crepet
 
AgileLunch Meetup - Listen to your Board
AgileLunch Meetup - Listen to your BoardAgileLunch Meetup - Listen to your Board
AgileLunch Meetup - Listen to your BoardFernando Cuenca
 
Kevinjohn Gallagher's: Emperors new clothes (WordUp Glasgow 2012)
Kevinjohn Gallagher's: Emperors new clothes (WordUp Glasgow 2012)Kevinjohn Gallagher's: Emperors new clothes (WordUp Glasgow 2012)
Kevinjohn Gallagher's: Emperors new clothes (WordUp Glasgow 2012)kevinjohngallagher
 
A Gentle introduction to microservices
A Gentle introduction to microservicesA Gentle introduction to microservices
A Gentle introduction to microservicesGianluca Padovani
 
Agile Development Practices - Productivity
Agile Development Practices - ProductivityAgile Development Practices - Productivity
Agile Development Practices - ProductivityAlex Moore
 
Grid Information systems from an Operations Perspective
Grid Information systems from an Operations PerspectiveGrid Information systems from an Operations Perspective
Grid Information systems from an Operations PerspectiveJames Casey
 
Intro to oop.pptx
Intro to oop.pptxIntro to oop.pptx
Intro to oop.pptxUmerUmer25
 
GDSC Backend Bootcamp.pptx
GDSC Backend Bootcamp.pptxGDSC Backend Bootcamp.pptx
GDSC Backend Bootcamp.pptxSaaraBansode
 
Code Quality Makes Your Job Easier
Code Quality Makes Your Job EasierCode Quality Makes Your Job Easier
Code Quality Makes Your Job EasierTonya Mork
 
WordCamp Nashville: Clean Code for WordPress
WordCamp Nashville: Clean Code for WordPressWordCamp Nashville: Clean Code for WordPress
WordCamp Nashville: Clean Code for WordPressmtoppa
 

Semelhante a OOP: Princípios e Padroes (20)

Design for Testability
Design for Testability Design for Testability
Design for Testability
 
Behavior-Driven Design: One Team's Exploration
Behavior-Driven Design: One Team's ExplorationBehavior-Driven Design: One Team's Exploration
Behavior-Driven Design: One Team's Exploration
 
Tdd2018 state of the software quality in Germany
Tdd2018 state of the software quality in GermanyTdd2018 state of the software quality in Germany
Tdd2018 state of the software quality in Germany
 
Mature agile teams essential patterns v4 - half day workshop
Mature agile teams   essential patterns v4 - half day workshopMature agile teams   essential patterns v4 - half day workshop
Mature agile teams essential patterns v4 - half day workshop
 
Pair Programming, TDD and other impractical things
Pair Programming, TDD and other impractical thingsPair Programming, TDD and other impractical things
Pair Programming, TDD and other impractical things
 
“Don’t Repeat Yourself”: 4 Process Street Features to Keep Work DRY
“Don’t Repeat Yourself”: 4 Process Street Features to Keep Work DRY“Don’t Repeat Yourself”: 4 Process Street Features to Keep Work DRY
“Don’t Repeat Yourself”: 4 Process Street Features to Keep Work DRY
 
Developing solid applications
Developing solid applicationsDeveloping solid applications
Developing solid applications
 
Visualizing Work: If you can't see it, you can't manage it
Visualizing Work: If you can't see it, you can't manage itVisualizing Work: If you can't see it, you can't manage it
Visualizing Work: If you can't see it, you can't manage it
 
15 Experts on the Art of JavaScript Programming
15 Experts on the Art of JavaScript Programming15 Experts on the Art of JavaScript Programming
15 Experts on the Art of JavaScript Programming
 
Better and Faster: A Journey Toward Clean Code and Enjoyment
Better and Faster: A Journey Toward Clean Code and EnjoymentBetter and Faster: A Journey Toward Clean Code and Enjoyment
Better and Faster: A Journey Toward Clean Code and Enjoyment
 
Design poo my_jug_en_ppt
Design poo my_jug_en_pptDesign poo my_jug_en_ppt
Design poo my_jug_en_ppt
 
AgileLunch Meetup - Listen to your Board
AgileLunch Meetup - Listen to your BoardAgileLunch Meetup - Listen to your Board
AgileLunch Meetup - Listen to your Board
 
Kevinjohn Gallagher's: Emperors new clothes (WordUp Glasgow 2012)
Kevinjohn Gallagher's: Emperors new clothes (WordUp Glasgow 2012)Kevinjohn Gallagher's: Emperors new clothes (WordUp Glasgow 2012)
Kevinjohn Gallagher's: Emperors new clothes (WordUp Glasgow 2012)
 
A Gentle introduction to microservices
A Gentle introduction to microservicesA Gentle introduction to microservices
A Gentle introduction to microservices
 
Agile Development Practices - Productivity
Agile Development Practices - ProductivityAgile Development Practices - Productivity
Agile Development Practices - Productivity
 
Grid Information systems from an Operations Perspective
Grid Information systems from an Operations PerspectiveGrid Information systems from an Operations Perspective
Grid Information systems from an Operations Perspective
 
Intro to oop.pptx
Intro to oop.pptxIntro to oop.pptx
Intro to oop.pptx
 
GDSC Backend Bootcamp.pptx
GDSC Backend Bootcamp.pptxGDSC Backend Bootcamp.pptx
GDSC Backend Bootcamp.pptx
 
Code Quality Makes Your Job Easier
Code Quality Makes Your Job EasierCode Quality Makes Your Job Easier
Code Quality Makes Your Job Easier
 
WordCamp Nashville: Clean Code for WordPress
WordCamp Nashville: Clean Code for WordPressWordCamp Nashville: Clean Code for WordPress
WordCamp Nashville: Clean Code for WordPress
 

Mais de Nelson Senna do Amaral

Mais de Nelson Senna do Amaral (9)

Veni vedi vici.
Veni vedi vici.Veni vedi vici.
Veni vedi vici.
 
Pague o aluguel
Pague o aluguelPague o aluguel
Pague o aluguel
 
Dando nome aos códigos
Dando nome aos códigosDando nome aos códigos
Dando nome aos códigos
 
Ruby Gotchas
Ruby GotchasRuby Gotchas
Ruby Gotchas
 
Domínio: Dividir e conquistar
Domínio: Dividir e conquistarDomínio: Dividir e conquistar
Domínio: Dividir e conquistar
 
Interfaces - Como os objetos deveriam se comportar
Interfaces - Como os objetos deveriam se comportarInterfaces - Como os objetos deveriam se comportar
Interfaces - Como os objetos deveriam se comportar
 
Nossa experiência com TDD
Nossa experiência com TDDNossa experiência com TDD
Nossa experiência com TDD
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Tirando o coelho da cartola: integrando sistemas com RabbitMQ
Tirando o coelho da cartola: integrando sistemas com RabbitMQTirando o coelho da cartola: integrando sistemas com RabbitMQ
Tirando o coelho da cartola: integrando sistemas com RabbitMQ
 

Último

Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 

Último (20)

Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Odoo Development Company in India | Devintelle Consulting Service
Odoo Development Company in India | Devintelle Consulting ServiceOdoo Development Company in India | Devintelle Consulting Service
Odoo Development Company in India | Devintelle Consulting Service
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 

OOP: Princípios e Padroes