Simple Code

1 101 vues

Publié le

Why Simple Code matters ?
Simplicity is the key for delivering the right software that matter

Publié dans : Technologie

Simple Code

  1. 1. Simple Code - The Simple Life in Software Land - 1 Rui Carvalho @rhwy :: rui.fr
  2. 2. I’m Agile, Should I care? 2
  3. 3. 3 Agile Cats
  4. 4. 4 Agile Cats follow XP rules
  5. 5. 5 Complexity is Everywhere
  6. 6. 6 Complexity is Everywhere and making things simple is hard!
  7. 7. 7 The Domain Complexity
  8. 8. Customer needs ‘Foo’ 8
  9. 9. …You think schema ‘Bar’ 9
  10. 10. Wrong models cause massive accidental complexity Greg Young 10
  11. 11. 11 Solving the wrong problem
  12. 12. 12 « It should go faster ! »
  13. 13. 13 Change the Engine, problem solved!
  14. 14. 14 Hidden Technical Complexity
  15. 15. 15 Frameworks?
  16. 16. 16
  17. 17. 17
  18. 18. 18 How big ?
  19. 19. 19 Config > Domain
  20. 20. A framework … = calls you 20
  21. 21. 21 You Call the Library
  22. 22. Bad Understanding Poor design No design Technology locking } Generates all that matters! Complexity ! 22
  23. 23. 23 Technical debt is watching you!
  24. 24. 24
  25. 25. Start simplicity now before it blows you! 25
  26. 26. 26 How to start ?
  27. 27. 27 Remember Agile Principles?
  28. 28. the 4 XP Simplicity Rules • Runs all the tests. • Expresses every idea that we need to express. • Says everything Once And Only Once. • Has no superfluous parts. 28 Kent Beck
  29. 29. the 4 elements of Simple design • Passes its tests • Minimizes duplication • Maximizes clarity • Has fewer elements 29
  30. 30. 2 final rules Developing strong skills of detecting duplication, removing duplication, identifying naming problems, and fixing naming problems equates to learning everything ever written about object-oriented 30 JbRains
  31. 31. 31 Simple Design Dynamo (c) jbrains 2013
  32. 32. 32 What else ?
  33. 33. Better Naming Iterate & refactor 33 Remove Duplication
  34. 34. What problem are trying to solve? Always! 34
  35. 35. Avoid coupling everywhere, from classes to libraries 35
  36. 36. Be Consistent Readability, Rules, Conventions 36
  37. 37. Be functional! Be declarative, Immutable, use lambdas 37
  38. 38. Practice ! Practice, Practice, Practice ! … 38
  39. 39. Get more Fun 39
  40. 40. All you need… http://c2.com/cgi/wiki? ExtremeProgrammingRoadmap 40 Simple Design Dynamo http://blog.thecodewhisperer.com/2013/12/07/ putting-an-age-old-battle-to-rest/
  41. 41. Hand written sketches are by me and can be reused under Creative Commons licence, other images are owned by their authors and I really would like to thank them if I found all credits … 41 @rhwy
  42. 42. 42 Add-on: lambda refactoring
  43. 43. 43 The Silence of the Lambas
  44. 44. 44 interface IPriceCalculator { double GetPrice(string productReference) } class Basket { IPriceCalculator calculator; public Basket(IPriceCalculator calculator) { this.calculator = calculator; } public Result AddProduct( Product product, int quantity) { Price = calculator.GetPrice(product.Reference); //other magic here } }
  45. 45. 45 class UserPriceCalculator : IPriceCalculator { public double GetPrice(string productReference) { //do some magic stuff here return price; } } var basket = new Basket(new UserPriceCalculator()); basket.AddProduct(theProduct, 2);
  46. 46. 46 class Basket { public Result AddProduct( Product product, int quantity, Func<string,double> calculator) { Price = calculator(product.Reference); //other magic } } var basket = new Basket(); basket.AddProduct(theProduct, 2, x=>x.rawPrice*0,85 );
  47. 47. 47 Add-on: More quotes
  48. 48. There is no good but some of them are useful 48 { Model | Architecture | persistance }
  49. 49. 49 “Templates, patterns, frameworks don’t solve anything” they are just tools to start faster

×