ݺߣ

ݺߣShare a Scribd company logo
Orientação a Objetos
ʰԳí辱Dz e ʲõ
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
‣ ʲõ de projeto (GoF)
OOP: ʰԳí辱Dz e Padroes
O que é Orientação a
Objetos?
OOP: ʰԳí辱Dz e Padroes
O método é apoiado por
quatro pilares
ٰçã
OOP: ʰԳí辱Dz e Padroes
ٰçã
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
OOP: ʰԳí辱Dz e Padroes
Encapsulamento
Onde podemos errar?
“No part of a complex system should
depend on the internal details of any
other part”
Ingalls, D.
Modularidade
OOP: ʰԳí辱Dz e Padroes
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
OOP: ʰԳí辱Dz e Padroes
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?
OOP: ʰԳí辱Dz e Padroes
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!
ʰԳí辱Dz
Least Astonishment
Command Query
Separation
Tell don’t ask
Law of Demeter
ʲõ
Decorator
Strategy
Chain of Responsibility
Composite
Template Method
Facade
ú岹?
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
Ad

Recommended

Mopping Up With Groovy
Mopping Up With Groovy
fuglylogic
Princípio DRY
Leonardo Lourenço Silva
Princípio law of demeter
Engenharia de Software Ágil
Melhorando seu código com Law of Demeter e Tell don't ask
Melhorando seu código com Law of Demeter e Tell don't ask
Nelson Senna do Amaral
Desenvolvimento Ágil com Play! Framework
Keuller Magalhães
L'illusione dell'ortogonalità
L'illusione dell'ortogonalità
Alberto Brandolini
10 Big Ideas from Industry
10 Big Ideas from Industry
Garth Gilmour
Writing Quality Code
Writing Quality Code
indikaMaligaspe
Design for Testability
Design for Testability
Pawel Kalbrun
Behavior-Driven Design: One Team's Exploration
Behavior-Driven Design: One Team's Exploration
dtcoutu
Tdd2018 state of the software quality in Germany
Tdd2018 state of the software quality in Germany
Orlovsky Consulting GbR
Mature agile teams essential patterns v4 - half day workshop
Mature agile teams essential patterns v4 - half day workshop
drewz lin
Pair Programming, TDD and other impractical things
Pair Programming, TDD and other impractical things
Marcello 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
LizzyManz
DDD tales from ProductLand - NewCrafts Paris - May 2024
DDD tales from ProductLand - NewCrafts Paris - May 2024
Alberto Brandolini
Developing solid applications
Developing solid applications
Nilesh 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 it
Fernando Cuenca
15 Experts on the Art of JavaScript Programming
15 Experts on the Art of JavaScript Programming
FusionCharts
Better and Faster: A Journey Toward Clean Code and Enjoyment
Better and Faster: A Journey Toward Clean Code and Enjoyment
Chris Holland
Design poo my_jug_en_ppt
Design poo my_jug_en_ppt
agnes_crepet
AgileLunch Meetup - Listen to your Board
AgileLunch Meetup - Listen to your Board
Fernando Cuenca
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 microservices
Gianluca Padovani
Agile Development Practices - Productivity
Agile Development Practices - Productivity
Alex Moore
Grid Information systems from an Operations Perspective
Grid Information systems from an Operations Perspective
James Casey
Intro to oop.pptx
Intro to oop.pptx
UmerUmer25
GDSC Backend Bootcamp.pptx
GDSC Backend Bootcamp.pptx
SaaraBansode
Code Quality Makes Your Job Easier
Code Quality Makes Your Job Easier
Tonya Mork
Veni vedi vici.
Veni vedi vici.
Nelson Senna do Amaral
Pague o aluguel
Pague o aluguel
Nelson Senna do Amaral

More Related Content

Similar to OOP: ʰԳí辱Dz e Padroes (20)

Design for Testability
Design for Testability
Pawel Kalbrun
Behavior-Driven Design: One Team's Exploration
Behavior-Driven Design: One Team's Exploration
dtcoutu
Tdd2018 state of the software quality in Germany
Tdd2018 state of the software quality in Germany
Orlovsky Consulting GbR
Mature agile teams essential patterns v4 - half day workshop
Mature agile teams essential patterns v4 - half day workshop
drewz lin
Pair Programming, TDD and other impractical things
Pair Programming, TDD and other impractical things
Marcello 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
LizzyManz
DDD tales from ProductLand - NewCrafts Paris - May 2024
DDD tales from ProductLand - NewCrafts Paris - May 2024
Alberto Brandolini
Developing solid applications
Developing solid applications
Nilesh 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 it
Fernando Cuenca
15 Experts on the Art of JavaScript Programming
15 Experts on the Art of JavaScript Programming
FusionCharts
Better and Faster: A Journey Toward Clean Code and Enjoyment
Better and Faster: A Journey Toward Clean Code and Enjoyment
Chris Holland
Design poo my_jug_en_ppt
Design poo my_jug_en_ppt
agnes_crepet
AgileLunch Meetup - Listen to your Board
AgileLunch Meetup - Listen to your Board
Fernando Cuenca
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 microservices
Gianluca Padovani
Agile Development Practices - Productivity
Agile Development Practices - Productivity
Alex Moore
Grid Information systems from an Operations Perspective
Grid Information systems from an Operations Perspective
James Casey
Intro to oop.pptx
Intro to oop.pptx
UmerUmer25
GDSC Backend Bootcamp.pptx
GDSC Backend Bootcamp.pptx
SaaraBansode
Code Quality Makes Your Job Easier
Code Quality Makes Your Job Easier
Tonya Mork
Behavior-Driven Design: One Team's Exploration
Behavior-Driven Design: One Team's Exploration
dtcoutu
Tdd2018 state of the software quality in Germany
Tdd2018 state of the software quality in Germany
Orlovsky Consulting GbR
Mature agile teams essential patterns v4 - half day workshop
Mature agile teams essential patterns v4 - half day workshop
drewz lin
Pair Programming, TDD and other impractical things
Pair Programming, TDD and other impractical things
Marcello 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
LizzyManz
DDD tales from ProductLand - NewCrafts Paris - May 2024
DDD tales from ProductLand - NewCrafts Paris - May 2024
Alberto Brandolini
Developing solid applications
Developing solid applications
Nilesh 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 it
Fernando Cuenca
15 Experts on the Art of JavaScript Programming
15 Experts on the Art of JavaScript Programming
FusionCharts
Better and Faster: A Journey Toward Clean Code and Enjoyment
Better and Faster: A Journey Toward Clean Code and Enjoyment
Chris Holland
Design poo my_jug_en_ppt
Design poo my_jug_en_ppt
agnes_crepet
AgileLunch Meetup - Listen to your Board
AgileLunch Meetup - Listen to your Board
Fernando Cuenca
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 microservices
Gianluca Padovani
Agile Development Practices - Productivity
Agile Development Practices - Productivity
Alex Moore
Grid Information systems from an Operations Perspective
Grid Information systems from an Operations Perspective
James Casey
GDSC Backend Bootcamp.pptx
GDSC Backend Bootcamp.pptx
SaaraBansode
Code Quality Makes Your Job Easier
Code Quality Makes Your Job Easier
Tonya Mork

More from Nelson Senna do Amaral (9)

Veni vedi vici.
Veni vedi vici.
Nelson Senna do Amaral
Pague o aluguel
Pague o aluguel
Nelson Senna do Amaral
Dando nome aos códigos
Dando nome aos códigos
Nelson Senna do Amaral
Ruby Gotchas
Ruby Gotchas
Nelson Senna do Amaral
Domínio: Dividir e conquistar
Domínio: Dividir e conquistar
Nelson Senna do Amaral
Interfaces - Como os objetos deveriam se comportar
Nelson Senna do Amaral
Nossa experiência com TDD
Nelson Senna do Amaral
Test Driven Development
Nelson Senna do Amaral
Tirando o coelho da cartola: integrando sistemas com RabbitMQ
Nelson Senna do Amaral
Interfaces - Como os objetos deveriam se comportar
Nelson Senna do Amaral
Nossa experiência com TDD
Nelson Senna do Amaral
Test Driven Development
Nelson Senna do Amaral
Tirando o coelho da cartola: integrando sistemas com RabbitMQ
Nelson Senna do Amaral
Ad

Recently uploaded (20)

Best Practice for LLM Serving in the Cloud
Best Practice for LLM Serving in the Cloud
Alluxio, Inc.
Decipher SEO Solutions for your startup needs.
Decipher SEO Solutions for your startup needs.
mathai2
Heat Treatment Process Automation in India
Heat Treatment Process Automation in India
Reckers Mechatronics
Threat Modeling a Batch Job Framework - Teri Radichel - AWS re:Inforce 2025
Threat Modeling a Batch Job Framework - Teri Radichel - AWS re:Inforce 2025
2nd Sight Lab
Test Case Design Techniques – Practical Examples & Best Practices in Software...
Test Case Design Techniques – Practical Examples & Best Practices in Software...
Muhammad Fahad Bashir
Streamlining CI/CD with FME Flow: A Practical Guide
Streamlining CI/CD with FME Flow: A Practical Guide
Safe Software
Open Source Software Development Methods
Open Source Software Development Methods
VICTOR MAESTRE RAMIREZ
Emvigo Capability Deck 2025: Accelerating Innovation Through Intelligent Soft...
Emvigo Capability Deck 2025: Accelerating Innovation Through Intelligent Soft...
Emvigo Technologies
openSAP_s4h27_Week_1_2025_All_ݺߣs.pdf
openSAP_s4h27_Week_1_2025_All_ݺߣs.pdf
Thomas Qiao
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
WSO2
Best MLM Compensation Plans for Network Marketing Success in 2025
Best MLM Compensation Plans for Network Marketing Success in 2025
LETSCMS Pvt. Ltd.
Key Challenges in Troubleshooting Customer On-Premise Applications
Key Challenges in Troubleshooting Customer On-Premise Applications
Tier1 app
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
IFI Techsolutions
The Anti-Masterclass Live - Peak of Data & AI 2025
The Anti-Masterclass Live - Peak of Data & AI 2025
Safe Software
Y - Recursion The Hard Way GopherCon EU 2025
Y - Recursion The Hard Way GopherCon EU 2025
Eleanor McHugh
Shell Skill Tree - LabEx Certification (LabEx)
Shell Skill Tree - LabEx Certification (LabEx)
VICTOR MAESTRE RAMIREZ
IDM Crack with Internet Download Manager 6.42 Build 41 [Latest 2025]
IDM Crack with Internet Download Manager 6.42 Build 41 [Latest 2025]
pcprocore
OpenChain Webinar - AboutCode - Practical Compliance in One Stack – Licensing...
OpenChain Webinar - AboutCode - Practical Compliance in One Stack – Licensing...
Shane Coughlan
Making significant Software Architecture decisions
Making significant Software Architecture decisions
Bert Jan Schrijver
Advance Doctor Appointment Booking App With Online Payment
Advance Doctor Appointment Booking App With Online Payment
AxisTechnolabs
Best Practice for LLM Serving in the Cloud
Best Practice for LLM Serving in the Cloud
Alluxio, Inc.
Decipher SEO Solutions for your startup needs.
Decipher SEO Solutions for your startup needs.
mathai2
Heat Treatment Process Automation in India
Heat Treatment Process Automation in India
Reckers Mechatronics
Threat Modeling a Batch Job Framework - Teri Radichel - AWS re:Inforce 2025
Threat Modeling a Batch Job Framework - Teri Radichel - AWS re:Inforce 2025
2nd Sight Lab
Test Case Design Techniques – Practical Examples & Best Practices in Software...
Test Case Design Techniques – Practical Examples & Best Practices in Software...
Muhammad Fahad Bashir
Streamlining CI/CD with FME Flow: A Practical Guide
Streamlining CI/CD with FME Flow: A Practical Guide
Safe Software
Emvigo Capability Deck 2025: Accelerating Innovation Through Intelligent Soft...
Emvigo Capability Deck 2025: Accelerating Innovation Through Intelligent Soft...
Emvigo Technologies
openSAP_s4h27_Week_1_2025_All_ݺߣs.pdf
openSAP_s4h27_Week_1_2025_All_ݺߣs.pdf
Thomas Qiao
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
WSO2
Best MLM Compensation Plans for Network Marketing Success in 2025
Best MLM Compensation Plans for Network Marketing Success in 2025
LETSCMS Pvt. Ltd.
Key Challenges in Troubleshooting Customer On-Premise Applications
Key Challenges in Troubleshooting Customer On-Premise Applications
Tier1 app
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
IFI Techsolutions
The Anti-Masterclass Live - Peak of Data & AI 2025
The Anti-Masterclass Live - Peak of Data & AI 2025
Safe Software
Y - Recursion The Hard Way GopherCon EU 2025
Y - Recursion The Hard Way GopherCon EU 2025
Eleanor McHugh
Shell Skill Tree - LabEx Certification (LabEx)
Shell Skill Tree - LabEx Certification (LabEx)
VICTOR MAESTRE RAMIREZ
IDM Crack with Internet Download Manager 6.42 Build 41 [Latest 2025]
IDM Crack with Internet Download Manager 6.42 Build 41 [Latest 2025]
pcprocore
OpenChain Webinar - AboutCode - Practical Compliance in One Stack – Licensing...
OpenChain Webinar - AboutCode - Practical Compliance in One Stack – Licensing...
Shane Coughlan
Making significant Software Architecture decisions
Making significant Software Architecture decisions
Bert Jan Schrijver
Advance Doctor Appointment Booking App With Online Payment
Advance Doctor Appointment Booking App With Online Payment
AxisTechnolabs
Ad

OOP: ʰԳí辱Dz e Padroes