SlideShare ist ein Scribd-Unternehmen logo
1 von 52
Downloaden Sie, um offline zu lesen
Isn’t this a design
  sofftek developer

  Skill traciende lenguajes

  Las bases que TODOS debemos
                                  patterns talk?
  tener.




Friday, October 14, 2011
aqui me pararia y me
      largaba
                             Object Oriented
                             Design - Basics



Friday, October 14, 2011
ME
                                                           Como me siento?

                                                           Con quienes he
                                                           colaborado?

                                                           En que cosas te
                                                           apasionas?




                     • Emmanuel Delgado
                     • Ingeniero de Software para Crowd
                           Interactive
                     • UAA, INEGI, Softtek
                     • PHP, Perl, Javascript, Java, Ruby
                     • Apasionadazo
                     • @chischaschos
Friday, October 14, 2011
What makes a system
                         complicated?
    code smell, you feel it

    mario c nice code, shit happens eveywhere


    same old problems




Friday, October 14, 2011
un cambio implica tocar
          muchos lugares




                                    Rigidity
Friday, October 14, 2011
cambio rompe lugares
       inesperados




                              Fragility
Friday, October 14, 2011
dificil hacer la cosa
     correcta

     de diseño

     de ambiente




                             Viscosity
Friday, October 14, 2011
duplicidad

          no puedes reutilizar
          componentes

          componentes utiles, pero
          separar es muy complicado




                                      Immobility
Friday, October 14, 2011
mas de lo que ocupas

        anticipas a
        requerimientos

        hard to understand




           Unnecessary complexity
Friday, October 14, 2011
resultado de reutilizar
     codigo copy paste




                           Unnecessary duplicity
Friday, October 14, 2011
la imagen es la misma

  tendencia dificil de entender

  codigo puede ser claro y legible

  requieres esfuerzo constante
  para seguir siendo leguible




                  Opacity



Friday, October 14, 2011
Rotten system usual smells
     •      Rigidity

     •      Fragility
                                      ocurren poco a poco un
                                      commit a la vez




     •      Viscosity

     •      Immobility

     •      Unnecessary duplicity and complexity

     •      Opacity



Friday, October 14, 2011
small building blocks

          small shapes

          Pequeñas formas ->
          grandes diseños

          Bellos?




             Small components design
                     principles
Friday, October 14, 2011
Single Responsibility (SR)

Friday, October 14, 2011
SR- How do I achieve
                                   it?


Friday, October 14, 2011
SR - Analyze your object


                     • Delegate
                     • Encapsulate what changes


Friday, October 14, 2011
SR - Delegate?




Friday, October 14, 2011
SR - Delegate! in ruby




Friday, October 14, 2011
SR - Delegate! in ruby




Friday, October 14, 2011
SR - Delegate! with rails




Friday, October 14, 2011
SR - Delegate! with rails




Friday, October 14, 2011
SR - Encapsulate what changes
                           interview question

                           Que es encapsular,
                           ejemplo ftp uploader

                           como ayuda churn,
                           idealmente los No picos



      +------------------------------------+---------------+
      | file_path                          | times_changed |
      +------------------------------------+---------------+
      | lib/churn/churn_calculator.rb      | 14            |
      | README.rdoc                        | 7             |
      | lib/tasks/churn_tasks.rb           | 6             |
      | Rakefile                           | 6             |
      | lib/churn/git_analyzer.rb          | 4             |
      | VERSION                            | 4             |
      | test/test_helper.rb                | 4             |
      | test/unit/churn_calculator_test.rb | 3             |
      | test/churn_test.rb                 | 3             |
      +------------------------------------+---------------+


Friday, October 14, 2011
OC - Open for extension
       closed for modification


Friday, October 14, 2011
OC - Don not reopen an
                 object




Friday, October 14, 2011
OP - Encapsulate and extend it




Friday, October 14, 2011
OC - Composition over
                     inheritance




Friday, October 14, 2011
OC - Composition
                             implemented




Friday, October 14, 2011
Dependency Inversion (DI)



Friday, October 14, 2011
DI - What is a dependency?
  dependencia agrega
  responsabilidades

  responsabilidad da
  razones para cambiar

  vas a tener que hacer
  cambios

  entre menos mejor, asi
  gastas mas tiempo
  creando codigo obra d arte




Friday, October 14, 2011
DI - Depend upon abstractions

     Si tu clase emplea servicios externos, o tiene
     muchas librerias requeridas,
       o ves demasiadas constantes, utilizalas tan tarde
     como puedas.




Friday, October 14, 2011
Basic suggestions
                     • Only one responsibility per object
                     • Encapsulate what changes
                     • Depend upon abstractions
                     • Delegate responsibilities
                     • Composition over inheritance
                     • Extend components, do not reopen them
Friday, October 14, 2011
patrones de diseño

      alguien identifico
      problemas comunes

      formas se repiten

      evita crear patrones
      hasta el ultimo momento




                    Afterwards common
                      shapes will arise
Friday, October 14, 2011
Observer


                     •     THINK: monitoring
                           behavior




Friday, October 14, 2011
Observer - An observer




Friday, October 14, 2011
Observer - The observed




Friday, October 14, 2011
Strategy


                     •     THINK: Interchangeable
                           algorithms




Friday, October 14, 2011
Strategy
     como llegas aqui? cuando
     un metodo ya tiene
     varios branchings




Friday, October 14, 2011
gy - Interchangeable algorithms


           como llegas aqui? cuando
           un metodo ya tiene
           varios branchings




 Friday, October 14, 2011
Proxy


                     •     THINK: Wrapping object
                           behavior, forward calls




Friday, October 14, 2011
Proxy




Friday, October 14, 2011
Template


                     •     THINK: Predefined steps




Friday, October 14, 2011
Template- Required?




Friday, October 14, 2011
Template- Implemented




Friday, October 14, 2011
Decorator


                     •     THINK: Present new
                           content based on
                           original content




Friday, October 14, 2011
Decorator - required?




Friday, October 14, 2011
Decorator - implemented




Friday, October 14, 2011
THE END



Friday, October 14, 2011
Conclusion

                     • Follow damn simple principles
                     • Do not program upon design patterns, let
                           them arise by themselves
                     • Refactor to design patterns


Friday, October 14, 2011
References - 1




Friday, October 14, 2011
References - 2
                     •     CHURN: https://github.com/danmayer/churn

                     •     http://vimeo.com/12350535

                     •     http://vimeo.com/26330100

                     •     http://confreaks.net/videos/257-larubyconf2009-the-building-
                           blocks-of-modularity

                     •     https://www.destroyallsoftware.com/screencasts




Friday, October 14, 2011
References - 3




Friday, October 14, 2011
References - 4

              pregunta para ustedes como mantienes el diseño
              dia tras dia?

              boy scout rule
              tdd
              refactor all the fucking time




Friday, October 14, 2011

Weitere ähnliche Inhalte

Andere mochten auch

Web Application Security
Web Application SecurityWeb Application Security
Web Application Securitysudip pudasaini
 
Sigma Xi Research Showcase 2013 - Reeto
Sigma Xi Research Showcase 2013 - ReetoSigma Xi Research Showcase 2013 - Reeto
Sigma Xi Research Showcase 2013 - ReetoReetobrata Basu
 
Passionate Programmer
Passionate ProgrammerPassionate Programmer
Passionate ProgrammerMagmaConf
 
Mike ramsey rexburg iwmm presentation
Mike ramsey rexburg iwmm presentationMike ramsey rexburg iwmm presentation
Mike ramsey rexburg iwmm presentationIWMM
 

Andere mochten auch (8)

Web Application Security
Web Application SecurityWeb Application Security
Web Application Security
 
Sigma Xi Research Showcase 2013 - Reeto
Sigma Xi Research Showcase 2013 - ReetoSigma Xi Research Showcase 2013 - Reeto
Sigma Xi Research Showcase 2013 - Reeto
 
BDD
BDDBDD
BDD
 
Security_Bootcamp_Intro
Security_Bootcamp_IntroSecurity_Bootcamp_Intro
Security_Bootcamp_Intro
 
Passionate Programmer
Passionate ProgrammerPassionate Programmer
Passionate Programmer
 
Corruption in India
Corruption in IndiaCorruption in India
Corruption in India
 
Mike ramsey rexburg iwmm presentation
Mike ramsey rexburg iwmm presentationMike ramsey rexburg iwmm presentation
Mike ramsey rexburg iwmm presentation
 
Web Architecture
Web ArchitectureWeb Architecture
Web Architecture
 

Ähnlich wie Oop design magma rails 2011

Devopsdays Goteborg 2011 - State of the Union
Devopsdays Goteborg 2011 - State of the UnionDevopsdays Goteborg 2011 - State of the Union
Devopsdays Goteborg 2011 - State of the UnionJohn Willis
 
Introduction to JavaScriptMVC
Introduction to JavaScriptMVCIntroduction to JavaScriptMVC
Introduction to JavaScriptMVCPedro Pimentel
 
Carton CPAN dependency manager
Carton CPAN dependency managerCarton CPAN dependency manager
Carton CPAN dependency managerTatsuhiko Miyagawa
 
Dev opsdays scriptcode
Dev opsdays scriptcodeDev opsdays scriptcode
Dev opsdays scriptcodeDevopsdays
 
Clouds against the Floods (RubyConfBR2011)
Clouds against the Floods (RubyConfBR2011) Clouds against the Floods (RubyConfBR2011)
Clouds against the Floods (RubyConfBR2011) Leonardo Borges
 
Usability tour-pceu-2011
Usability tour-pceu-2011Usability tour-pceu-2011
Usability tour-pceu-2011Puppet
 
DevOps Introduction @Cegeka
DevOps Introduction @CegekaDevOps Introduction @Cegeka
DevOps Introduction @Cegekadieterdm
 
Devops workshop unit2
Devops workshop unit2Devops workshop unit2
Devops workshop unit2John Willis
 
The Easy Way - Plone Conference 2011
The Easy Way - Plone Conference 2011The Easy Way - Plone Conference 2011
The Easy Way - Plone Conference 2011Mikko Ohtamaa
 
Generating Print Sales Leads with LinkedIn session 1
Generating Print Sales Leads with LinkedIn session 1Generating Print Sales Leads with LinkedIn session 1
Generating Print Sales Leads with LinkedIn session 1Joe Kern
 
Puppet camp europe 2011 hackability
Puppet camp europe 2011   hackabilityPuppet camp europe 2011   hackability
Puppet camp europe 2011 hackabilityPuppet
 
Community management
Community managementCommunity management
Community managementPaul Bradshaw
 
Plone IDE - the future of Plone development
Plone IDE - the future of Plone developmentPlone IDE - the future of Plone development
Plone IDE - the future of Plone developmentMikko Ohtamaa
 
Challenges in Large-Scale Web Crawling
Challenges in Large-Scale Web CrawlingChallenges in Large-Scale Web Crawling
Challenges in Large-Scale Web CrawlingNate Murray
 
Are Your Tests Really Helping You?
Are Your Tests Really Helping You?Are Your Tests Really Helping You?
Are Your Tests Really Helping You?LB Denker
 
Applied Kanban - Bizcamp 2011
Applied Kanban - Bizcamp 2011Applied Kanban - Bizcamp 2011
Applied Kanban - Bizcamp 2011wonko
 
Conquistando el Servidor con Node.JS
Conquistando el Servidor con Node.JSConquistando el Servidor con Node.JS
Conquistando el Servidor con Node.JSCaridy Patino
 
Go is your friend - Reppucci
Go is your friend - Reppucci Go is your friend - Reppucci
Go is your friend - Reppucci Codemotion
 

Ähnlich wie Oop design magma rails 2011 (20)

Devopsdays Goteborg 2011 - State of the Union
Devopsdays Goteborg 2011 - State of the UnionDevopsdays Goteborg 2011 - State of the Union
Devopsdays Goteborg 2011 - State of the Union
 
Introduction to JavaScriptMVC
Introduction to JavaScriptMVCIntroduction to JavaScriptMVC
Introduction to JavaScriptMVC
 
Carton CPAN dependency manager
Carton CPAN dependency managerCarton CPAN dependency manager
Carton CPAN dependency manager
 
Dev opsdays scriptcode
Dev opsdays scriptcodeDev opsdays scriptcode
Dev opsdays scriptcode
 
Clouds against the Floods (RubyConfBR2011)
Clouds against the Floods (RubyConfBR2011) Clouds against the Floods (RubyConfBR2011)
Clouds against the Floods (RubyConfBR2011)
 
Usability tour-pceu-2011
Usability tour-pceu-2011Usability tour-pceu-2011
Usability tour-pceu-2011
 
DevOps Introduction @Cegeka
DevOps Introduction @CegekaDevOps Introduction @Cegeka
DevOps Introduction @Cegeka
 
Devops workshop unit2
Devops workshop unit2Devops workshop unit2
Devops workshop unit2
 
The Easy Way - Plone Conference 2011
The Easy Way - Plone Conference 2011The Easy Way - Plone Conference 2011
The Easy Way - Plone Conference 2011
 
Generating Print Sales Leads with LinkedIn session 1
Generating Print Sales Leads with LinkedIn session 1Generating Print Sales Leads with LinkedIn session 1
Generating Print Sales Leads with LinkedIn session 1
 
Puppet camp europe 2011 hackability
Puppet camp europe 2011   hackabilityPuppet camp europe 2011   hackability
Puppet camp europe 2011 hackability
 
Community management
Community managementCommunity management
Community management
 
Plone IDE - the future of Plone development
Plone IDE - the future of Plone developmentPlone IDE - the future of Plone development
Plone IDE - the future of Plone development
 
Challenges in Large-Scale Web Crawling
Challenges in Large-Scale Web CrawlingChallenges in Large-Scale Web Crawling
Challenges in Large-Scale Web Crawling
 
Are Your Tests Really Helping You?
Are Your Tests Really Helping You?Are Your Tests Really Helping You?
Are Your Tests Really Helping You?
 
Applied Kanban - Bizcamp 2011
Applied Kanban - Bizcamp 2011Applied Kanban - Bizcamp 2011
Applied Kanban - Bizcamp 2011
 
Caridy patino - node-js
Caridy patino - node-jsCaridy patino - node-js
Caridy patino - node-js
 
Conquistando el Servidor con Node.JS
Conquistando el Servidor con Node.JSConquistando el Servidor con Node.JS
Conquistando el Servidor con Node.JS
 
Go is your friend
Go is your friendGo is your friend
Go is your friend
 
Go is your friend - Reppucci
Go is your friend - Reppucci Go is your friend - Reppucci
Go is your friend - Reppucci
 

Oop design magma rails 2011

  • 1. Isn’t this a design sofftek developer Skill traciende lenguajes Las bases que TODOS debemos patterns talk? tener. Friday, October 14, 2011
  • 2. aqui me pararia y me largaba Object Oriented Design - Basics Friday, October 14, 2011
  • 3. ME Como me siento? Con quienes he colaborado? En que cosas te apasionas? • Emmanuel Delgado • Ingeniero de Software para Crowd Interactive • UAA, INEGI, Softtek • PHP, Perl, Javascript, Java, Ruby • Apasionadazo • @chischaschos Friday, October 14, 2011
  • 4. What makes a system complicated? code smell, you feel it mario c nice code, shit happens eveywhere same old problems Friday, October 14, 2011
  • 5. un cambio implica tocar muchos lugares Rigidity Friday, October 14, 2011
  • 6. cambio rompe lugares inesperados Fragility Friday, October 14, 2011
  • 7. dificil hacer la cosa correcta de diseño de ambiente Viscosity Friday, October 14, 2011
  • 8. duplicidad no puedes reutilizar componentes componentes utiles, pero separar es muy complicado Immobility Friday, October 14, 2011
  • 9. mas de lo que ocupas anticipas a requerimientos hard to understand Unnecessary complexity Friday, October 14, 2011
  • 10. resultado de reutilizar codigo copy paste Unnecessary duplicity Friday, October 14, 2011
  • 11. la imagen es la misma tendencia dificil de entender codigo puede ser claro y legible requieres esfuerzo constante para seguir siendo leguible Opacity Friday, October 14, 2011
  • 12. Rotten system usual smells • Rigidity • Fragility ocurren poco a poco un commit a la vez • Viscosity • Immobility • Unnecessary duplicity and complexity • Opacity Friday, October 14, 2011
  • 13. small building blocks small shapes Pequeñas formas -> grandes diseños Bellos? Small components design principles Friday, October 14, 2011
  • 15. SR- How do I achieve it? Friday, October 14, 2011
  • 16. SR - Analyze your object • Delegate • Encapsulate what changes Friday, October 14, 2011
  • 17. SR - Delegate? Friday, October 14, 2011
  • 18. SR - Delegate! in ruby Friday, October 14, 2011
  • 19. SR - Delegate! in ruby Friday, October 14, 2011
  • 20. SR - Delegate! with rails Friday, October 14, 2011
  • 21. SR - Delegate! with rails Friday, October 14, 2011
  • 22. SR - Encapsulate what changes interview question Que es encapsular, ejemplo ftp uploader como ayuda churn, idealmente los No picos +------------------------------------+---------------+ | file_path | times_changed | +------------------------------------+---------------+ | lib/churn/churn_calculator.rb | 14 | | README.rdoc | 7 | | lib/tasks/churn_tasks.rb | 6 | | Rakefile | 6 | | lib/churn/git_analyzer.rb | 4 | | VERSION | 4 | | test/test_helper.rb | 4 | | test/unit/churn_calculator_test.rb | 3 | | test/churn_test.rb | 3 | +------------------------------------+---------------+ Friday, October 14, 2011
  • 23. OC - Open for extension closed for modification Friday, October 14, 2011
  • 24. OC - Don not reopen an object Friday, October 14, 2011
  • 25. OP - Encapsulate and extend it Friday, October 14, 2011
  • 26. OC - Composition over inheritance Friday, October 14, 2011
  • 27. OC - Composition implemented Friday, October 14, 2011
  • 29. DI - What is a dependency? dependencia agrega responsabilidades responsabilidad da razones para cambiar vas a tener que hacer cambios entre menos mejor, asi gastas mas tiempo creando codigo obra d arte Friday, October 14, 2011
  • 30. DI - Depend upon abstractions Si tu clase emplea servicios externos, o tiene muchas librerias requeridas, o ves demasiadas constantes, utilizalas tan tarde como puedas. Friday, October 14, 2011
  • 31. Basic suggestions • Only one responsibility per object • Encapsulate what changes • Depend upon abstractions • Delegate responsibilities • Composition over inheritance • Extend components, do not reopen them Friday, October 14, 2011
  • 32. patrones de diseño alguien identifico problemas comunes formas se repiten evita crear patrones hasta el ultimo momento Afterwards common shapes will arise Friday, October 14, 2011
  • 33. Observer • THINK: monitoring behavior Friday, October 14, 2011
  • 34. Observer - An observer Friday, October 14, 2011
  • 35. Observer - The observed Friday, October 14, 2011
  • 36. Strategy • THINK: Interchangeable algorithms Friday, October 14, 2011
  • 37. Strategy como llegas aqui? cuando un metodo ya tiene varios branchings Friday, October 14, 2011
  • 38. gy - Interchangeable algorithms como llegas aqui? cuando un metodo ya tiene varios branchings Friday, October 14, 2011
  • 39. Proxy • THINK: Wrapping object behavior, forward calls Friday, October 14, 2011
  • 41. Template • THINK: Predefined steps Friday, October 14, 2011
  • 44. Decorator • THINK: Present new content based on original content Friday, October 14, 2011
  • 45. Decorator - required? Friday, October 14, 2011
  • 48. Conclusion • Follow damn simple principles • Do not program upon design patterns, let them arise by themselves • Refactor to design patterns Friday, October 14, 2011
  • 49. References - 1 Friday, October 14, 2011
  • 50. References - 2 • CHURN: https://github.com/danmayer/churn • http://vimeo.com/12350535 • http://vimeo.com/26330100 • http://confreaks.net/videos/257-larubyconf2009-the-building- blocks-of-modularity • https://www.destroyallsoftware.com/screencasts Friday, October 14, 2011
  • 51. References - 3 Friday, October 14, 2011
  • 52. References - 4 pregunta para ustedes como mantienes el diseño dia tras dia? boy scout rule tdd refactor all the fucking time Friday, October 14, 2011