OOP: Princípios e Padroes

  • View
    129

  • Download
    0

Embed Size (px)

Transcript

  • Orientao a ObjetosPrincpios e Padres

  • Quem sou eu? Programador no Glio Trabalhei na Dafiti, Emprego Ligado e Tripda No mexo com PHP faz exatamente 1 ano Ruby @nelson_senna

  • Agenda

    Uma breve introduo a OOP Os primos pobres do S.O.L.I.D Padres de projeto (GoF)

  • O que Orientao a Objetos?

  • O mtodo apoiado por quatro pilares

  • Abstrao

  • AbstraoOnde 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

  • EncapsulamentoOnde podemos errar?

  • No part of a complex system should depend on the internal details of any

    other part

    Ingalls, D.

  • Modularidade

  • ModularidadeOnde 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

  • HierarquiaOnde 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 mltiplas instncias possam coexistir.

    Um troxa a

  • Objetos no so sacos de dados!

  • Princpios

  • Least Astonishment

  • Command Query Separation

  • Tell dont ask

  • Law of Demeter

  • Padres

  • Decorator

  • Strategy

  • Chain of Responsibility

  • Composite

  • Template Method

  • Facade

  • Dvidas?

  • 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

    https://flic.kr/p/mjweUhttps://flic.kr/p/6P7McXhttps://flic.kr/p/3QrzLyhttps://flic.kr/p/9sdBqQhttps://flic.kr/p/fgGtcPhttps://flic.kr/p/AD4FMh

  • Referncias Tell dont 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

    http://c2.com/cgi/wiki?PrincipleOfLeastAstonishmenthttps://8thlight.com/blog/doug-bradbury/2016/07/18/not-a-decorator-ruby.htmlhttps://medium.com/ruby-on-rails/what-i-learned-from-sandi-metz-9d0c94347b7f#.2y8u1prb4