Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
SOLID
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Gabriel Sobrinho
July 28, 2012
Programming
810
4
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
SOLID
Princípios para um melhor design de código
Gabriel Sobrinho
July 28, 2012
More Decks by Gabriel Sobrinho
See All by Gabriel Sobrinho
Arquiteturas Multi-Tenant RubyConf 2022
sobrinho
0
240
Introduction to Go
sobrinho
1
130
Casos de otimização em aplicações Ruby on Rails
sobrinho
0
330
Introduction to automated tests (Goiania)
sobrinho
0
180
Introduction to automated tests
sobrinho
3
250
Otimização de Aplicações RoR
sobrinho
1
300
Introdução ao React (Simplificado)
sobrinho
0
160
Algoritmos de pesquisa
sobrinho
0
700
Introdução ao Docker
sobrinho
1
130
Other Decks in Programming
See All in Programming
AIは賢い。でも実行環境は? CLIおじさんがAI時代に伝えたいこと ~ CLIおじさんがAI時代に伝えたいこと ~
curekoshimizu
1
240
cdk deploy JawsSonic #MARATHONしながらAWSリソースをデプロイしてみよう
akihisaikeda
2
130
速く作れる。その次は、速く確かめられる開発へ 〜AIネイティブ開発を支える、Shift Down〜 / Can build fast. Next, moving to development where we can verify fast.
rkaga
3
2.2k
AGENTS.md Is Not Enough:Build Skills, Don't Download Them
lx_t
0
120
【DroidKaigi 2026】「アクセシビリティを利用するとき、 アクセシビリティもまたこちらを利用している」 〜マルウェアによる攻撃と防衛について〜
halunoyo
0
460
JPUG勉強会 OSSデータベースの内部構造を理解しよう(第2回)
oga5
0
220
[GoCon2026] When Goroutines Are Not Enough: Runtime Locality in High-Throughput Go
takehaya
6
2.2k
{ Android | Kotlin } Gradle Plugin in 2026
ryunen344
1
320
一参加者から『中の人』へ 〜全通PHPerがブースに立って学んだ、カンファレンスを100倍楽しむコツ〜
wp_daisuke
0
150
仕様駆動開発による爆速プロダクト開発 / Bakusoku Spec Driven Development
kobakei
0
110
新卒PdEのリアル
ryu1013
1
500
GraphRAGのKnowledge Graphを 直接!見る/View-GraphRAG's-KnowledgeGraph-directly!
tyumugi1113
1
310
Featured
See All Featured
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
A Tale of Four Properties
chriscoyier
163
24k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
420
How STYLIGHT went responsive
nonsquared
100
6.3k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
740
For a Future-Friendly Web
brad_frost
183
10k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
5
650
The agentic SEO stack - context over prompts
schlessera
0
940
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.6k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.6k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
500
[RailsConf 2023] Rails as a piece of cake
palkan
59
7k
Transcript
SOLID princípios para um melhor design de código 1
WHO ARE WE? • @Sobrinho • Co-founder at Code5 •
Co-founder at Nohup • Co-founder at Hite • Software Architect • @MarceloCajueiro • Co-founder at Code5 • Project Leader at Nohup • Software Engineer 2
O QUE É SOLID? 3
POO 4
ORIENTAÇÃO A OBJETO Quais suas vantagens? 5
POO MAL FEITA É O MESMO QUE PROCEDURAL 6
HISTÓRIA • Introduzida pelo Uncle Bob (Robert Martin) em 2000
• Inspirado no subaproveitamento da POO • Com foco principal no acoplamento 7
SOLID • SRP - Single Responsibility Principle • OCP -
Open/Closed Principle • LSP - Liskov Substitution Principle • ISP - Interface Segregation Principle • DIP - Dependency Inversion Principle 8
SINGLE RESPONSIBILITY PRINCIPLE • Uma entidade (classe, método, módulo) deve
ter uma única responsabilidade • Responsabilidade pode ser definida como “razão para mudar” 9
Código ruim SRP 10
Aplicando o SRP SRP 11
OPEN-CLOSED PRINCIPLE (INICIALMENTE) • Uma classe deve estar aberta para
extensão mas fechada para modificação • Alterar a classe apenas para arrumar bugs • Novas funcionalidades são adicionadas em heranças 12
OPEN-CLOSED PRINCIPLE (ATUALMENTE) • Uma classe deve manter a sua
interface (API pública) • A implementação pode ser alterada livremente 13
Implementação mudou mas a interface (API pública) permeneceu OCP 14
LISKOV SUBSTITUTION PRINCIPLE • Deve ser possível substituir uma classe
por suas classes derivadas em qualquer ponto do código • As propriedades do programa não devem ser alteradas para isso acontecer 15
Pode-se usar qualquer uma das heranças e não irá quebrar
a classe que depende da interface (API pública) LSP 16
INTERFACE SEGREGATION PRINCIPLE • Classes não devem ser obrigadas a
depender de interfaces que elas não utilizam • Deve-se usar interfaces concisas, com apenas o que é realmente é usado • O SRP resolve este problema 17
Classe bala de prata ISP 18
Aplicando o SRP, se aplica o ISP ISP 19
DEPENDENCY INVERSION PRINCIPLE • Módulos de alto nível não devem
depender de módulos de baixo nível, ambos devem depender de abstrações (interface) • Abstrações não devem depender de detalhes, detalhes devem depender de abstrações 20
Código sem DIP (fortemente acoplado) DIP 21
E se eu quiser fazer cache ao invés de salvar
no banco de dados? DIP 22
Isso parece bom? DIP 23
Bye bye acoplamento DIP 24
SOLID • SRP - Single Responsibility Principle • OCP -
Open/Closed Principle • LSP - Liskov Substitution Principle • ISP - Interface Segregation Principle • DIP - Dependency Inversion Principle 25
DÚVIDAS? 26
REFERÊNCIAS • Edmilson Filho: http://www.slideshare.net/EdmilsonFilho2/princpios-solid-12117410 • Lucas Hungaro: http://www.slideshare.net/lucashungaro/solid-atravs-de-bdd-um-guia-prtico-para-rubistas •
Uncle Bob: http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod • Vinicius Quaiato: http://viniciusquaiato.com/blog/palestra-orientacao-a-objetos-e-principios-solid-slides-e-demos/ • Wikipedia: http://en.wikipedia.org/wiki/SOLID_(object-oriented_design) 27