ݺߣ

ݺߣ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

More Related Content

OOP: ʰԳí辱Dz e Padroes