• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Orientação a Objetos na prática em php
 

Orientação a Objetos na prática em php

on

  • 6,174 views

 

Statistics

Views

Total Views
6,174
Views on SlideShare
5,380
Embed Views
794

Actions

Likes
3
Downloads
252
Comments
0

3 Embeds 794

http://tisalvador.blogspot.com.br 566
http://tisalvador.blogspot.com 209
http://www.slideshare.net 19

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Orientação a Objetos na prática em php Orientação a Objetos na prática em php Presentation Transcript

    • Orientação a Objetos em PHP augusto@phpsp.org.br @augustohp Thursday, January 28, 2010
    • AUGUSTO PASCUTTI •4 anos de experiência • ZCE • Fundador/coordenador PHPSP • Habari, CakePHP Thursday, January 28, 2010
    • OBJETIVOS Thursday, January 28, 2010
    • ORIENTAR Thursday, January 28, 2010
    • PHP 5 Thursday, January 28, 2010
    • USAR Thursday, January 28, 2010
    • ORIENTANDO-SE Thursday, January 28, 2010
    • PROGRAMA PROCEDURAL ? Thursday, January 28, 2010
    • ESQUEÇA ! Thursday, January 28, 2010
    • PENSE DIFERENTE Thursday, January 28, 2010
    • PENSE OO Thursday, January 28, 2010
    • CLASSES Thursday, January 28, 2010
    • BASE DA OO Thursday, January 28, 2010
    • MOLDES Thursday, January 28, 2010
    • INSTRUÇÕES Thursday, January 28, 2010
    • SEM VONTADE PRÓPRIA Thursday, January 28, 2010
    • CLASSES Thursday, January 28, 2010
    • CLASSES Thursday, January 28, 2010
    • CLASSES Thursday, January 28, 2010
    • CLASSES Thursday, January 28, 2010
    • • Uma classe por arquivo • Padrões de nomenclatura • Padrão_Zend_ou_Pear CLASSES • PadrãoCamelCase • PaDrÃoMiGuXo Thursday, January 28, 2010
    • OBJETOS Thursday, January 28, 2010
    • FILHOS DAS CLASSES Thursday, January 28, 2010
    • INFORMAÇÕES Thursday, January 28, 2010
    • INDEPENDENTES Thursday, January 28, 2010
    • EXECUTORES Thursday, January 28, 2010
    • EXECUTAM Thursday, January 28, 2010
    • ATRIBUTOS Thursday, January 28, 2010
    • DECLARADOS NA CLASSE Thursday, January 28, 2010
    • USADOS NOS OBJETOS Thursday, January 28, 2010
    • PROPRIEDADES Thursday, January 28, 2010
    • INFORMAÇÕES Thursday, January 28, 2010
    • VARIÁVEIS Thursday, January 28, 2010
    • 4 Thursday, January 28, 2010
    • VARIÁVEIS Thursday, January 28, 2010
    • 5 Thursday, January 28, 2010
    • VARIÁVEIS Thursday, January 28, 2010
    • MÉTODOS Thursday, January 28, 2010
    • DECLARADOS NA CLASSE Thursday, January 28, 2010
    • USADOS PELOS OBJETOS Thursday, January 28, 2010
    • FUNÇÕES Thursday, January 28, 2010
    • FAZEM COISAS Thursday, January 28, 2010
    • DÃO E RECEBEM Thursday, January 28, 2010
    • 4 Thursday, January 28, 2010
    • DÃO E RECEBEM Thursday, January 28, 2010
    • 5 Thursday, January 28, 2010
    • DÃO E RECEBEM Thursday, January 28, 2010
    • AUTOLOAD Thursday, January 28, 2010
    • AUTOLOAD •Executado na instanciação •Executado somente para classes não declaradas •Nativo do PHP •Duas implementações •__autoload •SPL •Sem includes/requires •Melhora consumo de memória Thursday, January 28, 2010
    • AUTOLOAD Thursday, January 28, 2010
    • AUTOLOAD Thursday, January 28, 2010
    • MEMBROS DA CLASSE Thursday, January 28, 2010
    • CONSTANTES Thursday, January 28, 2010
    • CONSTANTES Thursday, January 28, 2010
    • ESTÁTICOS Thursday, January 28, 2010
    • ESTÁTICOS Thursday, January 28, 2010
    • ESTÁTICOS Thursday, January 28, 2010
    • MENSAGENS Thursday, January 28, 2010
    • PODER DA OO Thursday, January 28, 2010
    • TROCA DE INFORMAÇÕES Thursday, January 28, 2010
    • TROCA DE INFORMAÇÕES Thursday, January 28, 2010
    • HERANÇA Thursday, January 28, 2010
    • CLASSE PAI Thursday, January 28, 2010
    • CLASSE FILHA Thursday, January 28, 2010
    • VISIBILIDADE Thursday, January 28, 2010
    • PUBLIC Thursday, January 28, 2010
    • PROTECTED Thursday, January 28, 2010
    • PRIVATE Thursday, January 28, 2010
    • POLIMORFISMO Thursday, January 28, 2010
    • ERA UMA COISA Thursday, January 28, 2010
    • AGORA É OUTRA Thursday, January 28, 2010
    • SOBRECARGA Thursday, January 28, 2010
    • NA VERDADE: SOBRESCRITA Thursday, January 28, 2010
    • NA VERDADE: SOBRESCRITA Thursday, January 28, 2010
    • FINAL Thursday, January 28, 2010
    • IMPEDE O POLIMORFISMO Thursday, January 28, 2010
    • USADO EM CLASSES ... Thursday, January 28, 2010
    • E MÉTODOS Thursday, January 28, 2010
    • E MÉTODOS Thursday, January 28, 2010
    • ABSTRATO Thursday, January 28, 2010
    • NÃO PODE SER INSTANCIADA Thursday, January 28, 2010
    • USADA COMO PAI Thursday, January 28, 2010
    • USADA COMO PAI Thursday, January 28, 2010
    • USADA COMO PAI Thursday, January 28, 2010
    • MÁGICA Thursday, January 28, 2010
    • MÉTODOS MÁGICOS Thursday, January 28, 2010
    • EXECUTADOS PELO PHP Thursday, January 28, 2010
    • 14 EXISTENTES NO PHP 5.3 Thursday, January 28, 2010
    • SEMPRE COMEÇAM COM “_ _” Thursday, January 28, 2010
    • CONSTRUINDO Thursday, January 28, 2010
    • __CONSTRUCT •Executado na instanciação do objeto •Não pode retornar nada •Pode sofrer sobrecarga •Pode receber argumentos Thursday, January 28, 2010
    • __CONSTRUCT Thursday, January 28, 2010
    • DESTRUINDO Thursday, January 28, 2010
    • •Executado quando objeto sai da memória •Final do script •unset() do objeto •Pode ser útil em •Banco de dados •Logs •etc ... __DESTRUCT Thursday, January 28, 2010
    • __DESTRUCT Thursday, January 28, 2010
    • MOSTRANDO Thursday, January 28, 2010
    • __TOSTRING •Chamado quando objeto é usado como String •O método DEVE retornar uma String •Útil para objetos que devem retornar algo visual •Paginador, Botão •Até a versão 5.2 funcionava só com `print` e `echo` •> 5.2 funciona em qualquer contexto de string •TypeCast •sprintf() Thursday, January 28, 2010
    • __TOSTRING Thursday, January 28, 2010
    • OUTROS MÉTODOS MÁGICOS •__call •__get •__set •__get •__isset •__clone •http://php.net/manual/en/language.oop5.magic.php Thursday, January 28, 2010
    • INTERFACES Thursday, January 28, 2010
    • “CLASSES” GENÉRICAS Thursday, January 28, 2010
    • DEFINEM COMPORTAMENTOS Thursday, January 28, 2010
    • TIPOS DE DADOS Thursday, January 28, 2010
    • TIPOS DE DADOS Thursday, January 28, 2010
    • •Mais genéricos que Classes Abstratas •Uma classe pode implementar várias Interfaces TIPOS DE DADOS Thursday, January 28, 2010
    • EXCEPTIONS Thursday, January 28, 2010
    • TRABALHANDO Thursday, January 28, 2010
    • OBJETOS E REFERÊNCIAS Thursday, January 28, 2010
    • OBJETOS E REFERÊNCIAS Thursday, January 28, 2010
    • OBJETOS E REFERÊNCIAS Thursday, January 28, 2010
    • OBJETOS E REFERÊNCIAS Thursday, January 28, 2010
    • TYPE HINT Thursday, January 28, 2010
    • •Forçam um tipo a um argumento •Só podem ser usados como tipo: •Array •Classes TYPE HINT Thursday, January 28, 2010
    • TYPE HINT Thursday, January 28, 2010
    • TYPE HINT Thursday, January 28, 2010
    • INSTANCE OF Thursday, January 28, 2010
    • •Checa se um objeto é uma determinada instância •Retorna boolean •Um objeto pode ser checado contra •Classe •Classe Abstrata •Interface INSTANCE OF Thursday, January 28, 2010
    • INSTANCE OF Thursday, January 28, 2010
    • BANCO DE DADOS Thursday, January 28, 2010
    • ABSTRAIA Thursday, January 28, 2010
    • •Melhora segurança •Centraliza execuções •Melhor manutenção •Evita dor de cabeças ABSTRAIA Thursday, January 28, 2010
    • NÃO REINVENTE A RODA Thursday, January 28, 2010
    • USE A PDO Thursday, January 28, 2010
    • •O que ela é: •Abstração de Acesso para banco de dados •Nativo do PHP 5.1 •Aprenda uma sintaxe de conexão •Muito/Extremamente TESTADA pra caramba •Mais leve do que qualquer outra USE A PDO Thursday, January 28, 2010
    • •O que ela NÃO é: •Não abstrai suas queries •Não evita instalação de drivers dos bancos •Não vai resolver seus problemas •Nem de segurança •Nem de performance USE A PDO Thursday, January 28, 2010
    • USANDO A PDO Thursday, January 28, 2010
    • USANDO A PDO Thursday, January 28, 2010
    • •Agilizam a execução de queries repetidas •Implementam um pouco de segurança •Simplificam o uso de queries repetidas •Simplificam Fetch de resultados PDO STATEMENTS Thursday, January 28, 2010
    • PDO STATEMENTS Thursday, January 28, 2010
    • PARÂMETROS Thursday, January 28, 2010
    • RETORNO ID INSERIDO Thursday, January 28, 2010
    • DESIGN PATTERNS Thursday, January 28, 2010
    • •Solução comum para problemas comuns •Independem de linguagem •Vocuabulário comum •Primeiros DP: Gang of Four DESIGN PATTERNS Thursday, January 28, 2010
    • •Singleton •Factory •Strategy •Data Access Object •Value Objects •MVC DESIGN PATTERNS Thursday, January 28, 2010
    • FRAMEWORKS Thursday, January 28, 2010
    • Augusto Pascutti augusto@phpsp.org.br @augustohp http://www.slideshare.net/augustopascutti PERGUNTAS ? Thursday, January 28, 2010