Think horizontally @Codemotion


Published on

How to decouple, how to develop, how to choose the correct technology, few DDD concepts, and why BDD is so important.
How to Think...

Published in: Software, Technology
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Think horizontally @Codemotion

  1. 1. Codemotion ROME @bit_shark Andrea Giuliano Think horizontallydo not use lighters to open beers Giulio De Donato @liuggio 11-12 april 2014
  2. 2. Think horizontally @bit_shark @liuggio#codemotion hint We won't use technicisms and acronyms. Please see the references, we have had a lot of inspiration
  3. 3. thinking ideal @bit_shark @liuggio#codemotion Given an application with certain requirements which is the technology that fit the application requirements?
  4. 4. thinking real @bit_shark @liuggio#codemotion Given an application with certain requirements, I’m guru on Java I’ll use Java.
  5. 5. think too much… … at the same technology @bit_shark @liuggio#codemotion What’s wrong here? I’m developing a tech-centric application I’m fitting business requirements with technical boundaries
  6. 6. rethink to the origin @bit_shark @liuggio#codemotion But what about our preferred technology? Was it the coolest? The most requested for working? Or trivially the simplest?
  7. 7. think about laziness @bit_shark @liuggio#codemotion A developer should choose not the simplest tech The developer laziness drive the developer to reuse its code!
  8. 8. different thoughts @bit_shark @liuggio#codemotion A language can lack on some structural characteristic (polymorphism, strong typing)
  9. 9. think with ease @bit_shark @liuggio#codemotion The success of a language is it’s distributability (cheap, easy, zero-conf)?
  10. 10. a thought for thought @bit_shark @liuggio#codemotion There are successful application written in lacking languages The success of the business make the success of the application
  11. 11. thinking relational @bit_shark @liuggio#codemotion EAV thousand of libraries choose the relational model instead of schemaless • simplicity to distribute and install • even though some arguable tech detail
  12. 12. think to aim the success @bit_shark @liuggio#codemotion nosql Using the right technology in some cases could lead to a wrong choice
  13. 13. Shaggio theorem @bit_shark @liuggio#codemotion Hypothesis: supposing a developer knows every technology and make a good choice for a complex application Thesis: whatever will be the choice could be the wrong choice …we are thinking to the app as a one big global ‘entity'
  14. 14. think modular @bit_shark @liuggio#codemotion we want to split the application in as many as possible modules choosing the “right” technology for each module
  15. 15. think… @bit_shark @liuggio#codemotion • Split the business needs in subsets… a subset could be composed by services... • Spit and conquer and Object Oriented Design • If you have to implement a complex system, don’t implement a complex system, implement a lot of simple systems
  16. 16. think procedural @bit_shark @liuggio#codemotion developing with procedural is misleading, at the beginning you feel powerful, fast…
  17. 17. think WTF! @bit_shark @liuggio#codemotion • How many times you will modify the application, did you think about Maintenance costs? • Procedural is when you create a fast program (at the beginning) but difficult to maintain. “Tragically, the very same forces that make it so easy to add new features to a brand new Rails application are the ones that start to hold you back as the number of features grows.” cit. Matt Wynne
  18. 18. think connected Time Feature 😊 😁 😰 🏃 @bit_shark @liuggio#codemotion
  19. 19. think connected Time Feature 😊 😁 😰 🏃 @bit_shark @liuggio#codemotion • The procedural code is sick with a disease called "code connected” • Object-oriented programming is not immune • Time increases exponentially with the addition of new features.
  20. 20. think “Operation” @bit_shark @liuggio#codemotion All the programs are difficult to maintain, but decoupled software is easier How to understand if my code is decoupled? If you modify here and you don’t break over there.
  21. 21. Time Feature think maintainability @bit_shark @liuggio#codemotion TDD
  22. 22. Time Feature think maintainability @bit_shark @liuggio#codemotion TDD • Modularity is the main concept of Object Oriented Design • The trend has changed (90 years ago), now we have to focus on maintainability • The overhead of testing before code is smaller than you think and the real adding value is the way you develop better your application
  23. 23. Think back to ‘89 @bit_shark @liuggio#codemotion responsability driven approach! SOLID principles • R. Wirfs-Brock, B. Wilkerson, “Object-Oriented Design: A Responsibility-Driven Approach” • Single responsibility principle Uncle Bob • Create a module coupling things that changes together? • Modules that communicates, but how?
  24. 24. think tell don’t ask Matt Wayne, Uncle Bob, Alec Sharp and Martin Fowler @bit_shark @liuggio#codemotion
  25. 25. think behaviour @bit_shark @liuggio#codemotion dependency injection • Modules that communicate via protocols • Modules that exhibit a behavior not their data • Data are the guts of the module, they must not be exposed • All the public functions are API, let's take care and give them a meaning. • Each module should have its own explicit dependencies
  26. 26. think and code @bit_shark @liuggio#codemotion 1. An employee has always a name and a salary! 2. The salary is always greater than zero! 3. A company could add an employee
  27. 27. think and code @bit_shark @liuggio#codemotion 1. An employee has always a name and a salary! 2. The salary is always greater than zero! 3. A company could add an employee
  28. 28. @bit_shark @liuggio#codemotion think invariant 1. An employee has always a name and a salary! 2. The salary is always greater than zero! 3. A company could add an employee
  29. 29. @bit_shark @liuggio#codemotion think consistent 1. An employee has always a name and a salary! 2. The salary is always greater than zero! 3. A company could add an employee
  30. 30. @bit_shark @liuggio#codemotion think business language 3. A company could hire an employee 1. An employee has always a name and a salary! 2. The salary is always greater than zero! 3. A company could add an employee
  31. 31. think behaviour not data @bit_shark @liuggio#codemotion Bdd! specification
  32. 32. think
 Behaviour Driven Development @bit_shark @liuggio#codemotion That's why with BDD (stories and specs) you are more forced not to test the application but you focus on describe the behaviors. With BDD you tend to describes the behavior before coding, you specify what a function should do.
  33. 33. think behaviour defer implementation @bit_shark @liuggio#codemotion
  34. 34. think onion @bit_shark @liuggio#codemotion hexagonal Database as implementation detail Framework as implementation detail
  35. 35. think to clean the Architecture Application goal: separation of concerns Easy substitution of obsolete elements without affecting others components of the architecture
  36. 36. Andrea Giuliano @bit_shark Giulio De Donato @liuggio T h i n k y o u ! Thank
  37. 37. References - Growing Object-Oriented Software by Guided by Tests, Steve Freeman, Nat Pryce - Implementing Domain-Driven Design by Vaughn Vernon - Unbreakable Domain Models by Mathias Verraes - Uncle Bob the clean Architecture the-clean-architecture.html - DDD community - Matt Wayne GoRuCo 2012 Hexagonal Rails by Matt Wynne - Implementing Domain-Driven Design with Spring and vFabric Wes Williams, Vaughn Vernon - The RSpec Book Behaviour-Driven Development with RSpec, Cucumber, and Friends by David Chelimsky, Dave Astels, Zach Dennis, Aslak Hellesøy, Bryan Helmkamp, Dan North - Alberto Brandolini Assets