Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Programação defensiva com PHP
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Joubert RedRat
September 15, 2025
Technology
37
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Programação defensiva com PHP
Joubert RedRat
September 15, 2025
More Decks by Joubert RedRat
See All by Joubert RedRat
Testes de integração com Testcontainers
joubertredrat
0
51
Retome o controle do seu analytics com Matomo
joubertredrat
0
52
#tbt do PHP, a evolução da linguagem nos últimos 30 anos
joubertredrat
0
53
DevBox, o meu pequeno projeto open source para o dia a dia do dev
joubertredrat
0
48
O poder do Object Calisthenics no PHP
joubertredrat
0
160
Playing with Docker and Docker Compose
joubertredrat
0
170
Why migrate your application to microservices?
joubertredrat
0
43
Por que migrar sua aplicação para Microserviços?
joubertredrat
0
42
Uso prático de fakes para mocks no Golang
joubertredrat
0
93
Other Decks in Technology
See All in Technology
少人数データチームのDevin活用実践事例
runandy16
2
440
DINO-EdgeQuery:Edge-First Polygon Decoding for Building Footprint Extraction from Satellite Imagery
lehupa
0
150
enechainの内製セルフサービスプラットフォーム
hiyosi
0
110
When Does a Local Qwen Start to Break
morshoto
0
180
AI時代のAPI品質を支えるガードレール / API Guardrails for API quality in the AI era
yokawasa
1
120
PM領域でのAI Agentの活用
lycorptech_jp
PRO
0
270
リージョンの壁を越える、 ちょっと変わったAWSサービスの話
falken
PRO
0
260
コスト最適化の「めんどくさい」を AWS FinOps Agent でチョット楽にする
classmethod_kaz
0
230
Where Is JetBrains AI Heading- — Central CLI, Air Alpha, and the Agentic Development Stack
x5gtrn
PRO
0
130
2026-09-04 SRE Tech Talk #15 怠惰なTerraform / Lazy Terraform
masasuzu
0
200
Bet AI Day 2026丨AIによって本質に戻るシステムリスク管理
layerx
PRO
0
1k
データエンジニアの困りごとをDevinと一緒に解消する
10xinc
2
830
Featured
See All Featured
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
1
400
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
710
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
440
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
A Soul's Torment
seathinner
7
3.5k
Six Lessons from altMBA
skipperchong
29
4.5k
Visualization
eitanlees
152
17k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
320
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.4k
Designing Powerful Visuals for Engaging Learning
tmiket
1
530
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
420
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.6k
Transcript
Programação defensiva com PHP
Quem sou eu? Sou este ai https://creativecommons.org/licenses/by-sa/4.0/ https://redrat.com.br
Eu não sou uma entidade divina O que eu falo
não é uma verdade absoluta, não tenha medo de questionar
Programação defensiva O que deve ser?
Programação defensiva
Programação defensiva • Antecipação e resolução de possíveis problemas •
Prevenção de travamentos • Maior garantia de estabilidade e segurança • Confiabilidade e robustez
None
None
Esse trecho de código funciona?
Sim, mas pode ser melhor
None
None
Técnicas usadas Validação no Construtor Validação do e-mail imediatamente na
criação do objeto Type Hinting Tipagem do $email como uma string
Técnicas usadas Imutabilidade Propriedade readonly impede alterações após criação Validação
de Formato Uso do FILTER_VALIDATE_EMAIL para verificar string como formato válido
Técnicas usadas Fail Fast Lançamento de exceção por dados inválidos
DTO Pattern Separação da validação de dados da lógica de negócio
Técnicas Comuns
Validação de entrada de dados • Verificar campos obrigatórios •
Validar formato (e-mail, CPF) • Limitar tamanho de strings • Garantir tipo de dado (número)
Tratamento de Exceções • Capturar exceções • Lidar com falhas
de rede • Registrar exceções inesperadas
Fail-first / Fail-early • Detectar entradas incorretas rapidamente • Interromper
a execução imediatamente • Evitar propagação de dados inválidos • Garantir maior confiabilidade do sistema
Segurança • Sanitizar entradas (SQL Injection) • Escapar saídas (XSS)
• Validar permissões de usuário • Criptografar dados sensíveis
Robustez de Funções e Métodos • Checar argumentos nulos •
Validar estado do objeto • Garantir pré-condições • Verificar pós-condições
Benefícios • Reduzir erros e falhas • Aumentar a estabilidade
do software • Reforçar a segurança da aplicação • Facilitar a manutenção e melhorar a coesão • Otimizar a experiência do usuário
Perguntas?
Esta e outras palestras https://bit.ly/joubertredrat-palestras
Obrigado