Principios SOLID para el diseño orientado a objetos
-
Upload
netmind -
Category
Technology
-
view
378 -
download
3
description
Transcript of Principios SOLID para el diseño orientado a objetos
![Page 1: Principios SOLID para el diseño orientado a objetos](https://reader033.fdocuments.ec/reader033/viewer/2022051514/5499f2e8ac795959288b5b72/html5/thumbnails/1.jpg)
SOLID design principles
![Page 2: Principios SOLID para el diseño orientado a objetos](https://reader033.fdocuments.ec/reader033/viewer/2022051514/5499f2e8ac795959288b5b72/html5/thumbnails/2.jpg)
En el inicio...
![Page 3: Principios SOLID para el diseño orientado a objetos](https://reader033.fdocuments.ec/reader033/viewer/2022051514/5499f2e8ac795959288b5b72/html5/thumbnails/3.jpg)
El software
cambia
![Page 4: Principios SOLID para el diseño orientado a objetos](https://reader033.fdocuments.ec/reader033/viewer/2022051514/5499f2e8ac795959288b5b72/html5/thumbnails/4.jpg)
Rigido
cambios en cascada
![Page 5: Principios SOLID para el diseño orientado a objetos](https://reader033.fdocuments.ec/reader033/viewer/2022051514/5499f2e8ac795959288b5b72/html5/thumbnails/5.jpg)
Fragil
elementos no
relacionados se
rompen al hacer
un cambio
![Page 6: Principios SOLID para el diseño orientado a objetos](https://reader033.fdocuments.ec/reader033/viewer/2022051514/5499f2e8ac795959288b5b72/html5/thumbnails/6.jpg)
Inamovible
poca reutilización
copy-paste
![Page 7: Principios SOLID para el diseño orientado a objetos](https://reader033.fdocuments.ec/reader033/viewer/2022051514/5499f2e8ac795959288b5b72/html5/thumbnails/7.jpg)
Pringoso
es dificil entender
el diseño inicial
abres, cierras y
bye
![Page 8: Principios SOLID para el diseño orientado a objetos](https://reader033.fdocuments.ec/reader033/viewer/2022051514/5499f2e8ac795959288b5b72/html5/thumbnails/8.jpg)
SOLID no todo son principios
![Page 9: Principios SOLID para el diseño orientado a objetos](https://reader033.fdocuments.ec/reader033/viewer/2022051514/5499f2e8ac795959288b5b72/html5/thumbnails/9.jpg)
SOLID = gestión dependencias
las dependencias te matan
diseño te salva
![Page 10: Principios SOLID para el diseño orientado a objetos](https://reader033.fdocuments.ec/reader033/viewer/2022051514/5499f2e8ac795959288b5b72/html5/thumbnails/10.jpg)
Que son dependencias?
framework
var cutomer = new Customer()
web services
BD
![Page 11: Principios SOLID para el diseño orientado a objetos](https://reader033.fdocuments.ec/reader033/viewer/2022051514/5499f2e8ac795959288b5b72/html5/thumbnails/11.jpg)
Hipótesis
http://martinfowler.com/bliki/DesignStaminaHypothesis.html
![Page 12: Principios SOLID para el diseño orientado a objetos](https://reader033.fdocuments.ec/reader033/viewer/2022051514/5499f2e8ac795959288b5b72/html5/thumbnails/12.jpg)
€
Si el proyecto sigue vivo,
te costará más dinero
![Page 13: Principios SOLID para el diseño orientado a objetos](https://reader033.fdocuments.ec/reader033/viewer/2022051514/5499f2e8ac795959288b5b72/html5/thumbnails/13.jpg)
SOLID
Michael Feathers for the "First five principles" Robert C Martin SOLID http://social.technet.microsoft.com/wiki/contents/articles/18033.software-design-principles.aspx
![Page 14: Principios SOLID para el diseño orientado a objetos](https://reader033.fdocuments.ec/reader033/viewer/2022051514/5499f2e8ac795959288b5b72/html5/thumbnails/14.jpg)
Single responsability
Open/closed
Liskov substitution
Interface segregation
Dependency Inversion
![Page 15: Principios SOLID para el diseño orientado a objetos](https://reader033.fdocuments.ec/reader033/viewer/2022051514/5499f2e8ac795959288b5b72/html5/thumbnails/15.jpg)
Single Responsability
"A class should have only one reason to change. " http://social.technet.microsoft.com/wiki/contents/articles/18061.single-responsibility-principle.aspx
![Page 16: Principios SOLID para el diseño orientado a objetos](https://reader033.fdocuments.ec/reader033/viewer/2022051514/5499f2e8ac795959288b5b72/html5/thumbnails/16.jpg)
Open - Closed
"Open for extension, closed for modification"
![Page 17: Principios SOLID para el diseño orientado a objetos](https://reader033.fdocuments.ec/reader033/viewer/2022051514/5499f2e8ac795959288b5b72/html5/thumbnails/17.jpg)
Liskov substitution
"Derived classes must be able to substitute for their base classes" Child class must not remove base class behavior
![Page 18: Principios SOLID para el diseño orientado a objetos](https://reader033.fdocuments.ec/reader033/viewer/2022051514/5499f2e8ac795959288b5b72/html5/thumbnails/18.jpg)
Interface segregation
"many client-specific interfaces are better than one general-purpose interface."
http://social.technet.microsoft.com/wiki/contents/articles/18061.single-responsibility-principle.aspx
![Page 19: Principios SOLID para el diseño orientado a objetos](https://reader033.fdocuments.ec/reader033/viewer/2022051514/5499f2e8ac795959288b5b72/html5/thumbnails/19.jpg)
Dependency Inversion
"High level modules should not depend upon low level modules, rather both should depend upon abstractions" http://social.technet.microsoft.com/wiki/contents/articles/18061.single-responsibility-principle.aspx
![Page 20: Principios SOLID para el diseño orientado a objetos](https://reader033.fdocuments.ec/reader033/viewer/2022051514/5499f2e8ac795959288b5b72/html5/thumbnails/20.jpg)
OCP = Objetivo
SRP + DIP = estrategias de código
LSP= formula confusa
ISP = No parece tener aplicación
![Page 21: Principios SOLID para el diseño orientado a objetos](https://reader033.fdocuments.ec/reader033/viewer/2022051514/5499f2e8ac795959288b5b72/html5/thumbnails/21.jpg)
Al final todo va de gestión de dependencias
![Page 22: Principios SOLID para el diseño orientado a objetos](https://reader033.fdocuments.ec/reader033/viewer/2022051514/5499f2e8ac795959288b5b72/html5/thumbnails/22.jpg)
El diseño va de dependencias
Si haces referencia a algo ----> dependes de
ello
Si tu dependencia cambia ----> tu debes cambiar
![Page 23: Principios SOLID para el diseño orientado a objetos](https://reader033.fdocuments.ec/reader033/viewer/2022051514/5499f2e8ac795959288b5b72/html5/thumbnails/23.jpg)
para evitar dependencias
loosely coupled - DIP
highly cohesive - SRP
easily composable - dependencias
context independent - dependencias
http://www.growing-object-oriented-software.com/
![Page 24: Principios SOLID para el diseño orientado a objetos](https://reader033.fdocuments.ec/reader033/viewer/2022051514/5499f2e8ac795959288b5b72/html5/thumbnails/24.jpg)
código independencia
Single responsability
Dependency Inversion
Open/closed
Liskov substitution - > subclases
Interface segregation -> static languages
http://www.growing-object-oriented-software.com/
![Page 25: Principios SOLID para el diseño orientado a objetos](https://reader033.fdocuments.ec/reader033/viewer/2022051514/5499f2e8ac795959288b5b72/html5/thumbnails/25.jpg)
código!
![Page 26: Principios SOLID para el diseño orientado a objetos](https://reader033.fdocuments.ec/reader033/viewer/2022051514/5499f2e8ac795959288b5b72/html5/thumbnails/26.jpg)
Inversion de dependencias
UI
Business Logic
Data access
![Page 27: Principios SOLID para el diseño orientado a objetos](https://reader033.fdocuments.ec/reader033/viewer/2022051514/5499f2e8ac795959288b5b72/html5/thumbnails/27.jpg)
Inversion de dependencias
UI
Business Logic
Data access
![Page 28: Principios SOLID para el diseño orientado a objetos](https://reader033.fdocuments.ec/reader033/viewer/2022051514/5499f2e8ac795959288b5b72/html5/thumbnails/28.jpg)
Resistencia
code smell
abraza el problema, y arreglalo
![Page 29: Principios SOLID para el diseño orientado a objetos](https://reader033.fdocuments.ec/reader033/viewer/2022051514/5499f2e8ac795959288b5b72/html5/thumbnails/29.jpg)
test depende de ---> tu código
TDD se hace complicado si no hay diseño
![Page 30: Principios SOLID para el diseño orientado a objetos](https://reader033.fdocuments.ec/reader033/viewer/2022051514/5499f2e8ac795959288b5b72/html5/thumbnails/30.jpg)
autoexamen
existe repetición?
tiene una responsabilidad?
cambia todo al mismo ritmo?
depende de cosas que cambian poco?
![Page 31: Principios SOLID para el diseño orientado a objetos](https://reader033.fdocuments.ec/reader033/viewer/2022051514/5499f2e8ac795959288b5b72/html5/thumbnails/31.jpg)
Fin