Advertisement

Emergent design with phpspec

Lean/Agile Coach at Ovo Energy
Jun. 8, 2013
Advertisement

More Related Content

Advertisement

Recently uploaded(20)

Emergent design with phpspec

  1. by@_md emergentdesignwith
  2. Iworkhere Icontributehere Itweethere @_md MarcelloDuarte
  3. it’s2007
  4. @padraicb @tswicegood
  5. aportforrspec
  6. !== http://earthymoon.deviantart.com/art/Elephant-png-122633500 http://sonylisation.deviantart.com/art/Ruby-Nr-2-207831683
  7. bowling.score.should eq(0)
  8. inrubyeverythingisanobject andallobjectsareopen bowling.score.should eq(0)
  9. inrubyeverythingisanobject andallobjectsareopen http://www.flickr.com/photos/owenbooth/126288240/ bowling.score.should eq(0)
  10. inrubyeverythingisanobject andallobjectsareopen http://www.flickr.com/photos/owenbooth/126288240/ bowling.score.should eq(0)
  11. $this->spec($bowling->getScore()) ->shouldEqual(0); PHPSPECEARLYSYNTAXEXAMPLE
  12. http://www.flickr.com/photos/jamesrbowe/8403688026/ amber... red... green...
  13. md@bossa:tests $ phpunit . PHPUnit 3.7.14 by Sebastian Bergmann. PHP Fatal error: Class 'Customer' not found in /Users/mduarte/Documents/NoSync/Lab/phpunit/ tests/CustomerTest.php on line 8 Fatal error: Class 'Customer' not found in / Users/mduarte/Documents/NoSync/Lab/phpunit/ tests/CustomerTest.php on line 8
  14. yougottabemockingme!
  15. public function testUpdateWithEqualTypes() { $installer = $this->createInstallerMock(); $manager = new InstallationManager('vendor'); $manager->addInstaller($installer); $initial = $this->createPackageMock(); $target = $this->createPackageMock(); $operation = new UpdateOperation($initial, $target, 'test'); $initial ->expects($this->once()) ->method('getType') ->will($this->returnValue('library')); $target ->expects($this->once()) ->method('getType') ->will($this->returnValue('library')); $installer ->expects($this->once()) ->method('supports') ->with('library') ->will($this->returnValue(true)); $installer ->expects($this->once()) ->method('update') ->with($this->repository, $initial, $target);
  16. @_md @everzet
  17. goals { funtoworkwith
  18. goals {developmenttool funtoworkwith
  19. goals {developmenttool let’snotgetintheway funtoworkwith
  20. goals {enforce(mockist)TDD developmenttool let’snotgetintheway funtoworkwith
  21. goals {enforce(mockist)TDD doitthePHPway developmenttool let’snotgetintheway funtoworkwith
  22. { "require-dev": { "phpspec/phpspec": "2.0.*@dev" }, "config": { "bin-dir": "bin" }, "autoload": { "psr-0": { "": "src" } } }
  23. $ bin/phpspec describe Some/Class$ bin/phpspec describe Some/Class
  24. $ bin/phpspec describe Some/Class $ bin/phpspec run $ bin/phpspec describe Some/Class $ bin/phpspec run
  25. $ bin/phpspec describe Some/Class $ bin/phpspec run phpspec generators $ bin/phpspec describe Some/Class $ bin/phpspec run phpspec generators
  26. $ bin/phpspec describe Some/Class $ bin/phpspec run $ editor_of_choice . phpspec generators $ bin/phpspec describe Some/Class $ bin/phpspec run $ editor_of_choice . phpspec generators
  27. $ bin/phpspec describe Some/Class $ bin/phpspec run $ editor_of_choice . phpspec generators $ bin/phpspec describe Some/Class $ bin/phpspec run $ editor_of_choice . phpspec generators
  28. $ bin/phpspec describe Some/Class $ bin/phpspec run $ editor_of_choice . phpspec generators $ bin/phpspec describe Some/Class $ bin/phpspec run $ editor_of_choice . phpspec generators
  29. littledemo
  30. emergentdesign
  31. designemergeiterativelydrivenbytests
  32. design is ...
  33. designsoftware is ...
  34. designsoftware is todescribehowwe’resolvingaproblem
  35. calculatecostvarianceforaperiod
  36. calculatecostvarianceforaperiod Period
  37. firstlearndesign,thenemergentdesign
  38. “Key in making great and growable systems is to design how its modules communicate [andnot]whattheirpropertiesandbehavioursshouldbe.” Messaging ViewpointsResearchInstituteSource-BonnieMacbirdURL-http://www.vpri.org
  39. messaging
  40. $this->person->getCar()->getEngine()->ignite();
  41. focusonmessaging makesthecodeflexible
  42. $this->person->startCar();
  43. describinghowobjectsinteracttosolveproblems whichroles,responsibilitiesandmessages designsoftware is
  44. bigdesignupfront
  45. IT’SHARDTOCHANGELATER.
  46. WENEEDTOTHINKABOUTTHINGSBEFOREDEVELOPING.
  47. WENEEDTOMAKESUREWEDON’TMISSANYTHING.
  48. THISISJUSTTHEWAYWEDOIT.
  49. relativecostofrepaircost time analysis design code test deploy rework $
  50. yagni
  51. 61% oftherequestedfeaturesareactuallydelivered [Standish Group Report 06]
  52. 27% ofrequestedfeaturesareactuallyused
  53. 5% to 10% areresponsibleforrealisingthebenefitsenvisioned
  54. designforthehighpriorityitems andmakeiteasytochangelater
  55. describinghowobjectsinteracttosolveproblems whichroles,responsibilitiesandmessages inachange-friendlyway designsoftwareinagile is
  56. easiersaidthandone?
  57. test coderefactor
  58. usesimpledesignrulestorefactor 1.Alltestsrunandpass 2.Removeduplication 3.Removeopacity 4.Removecomplexity
  59. resultsincode 1.Testable 2.Modular 3.Expressive 4.Simple
  60. lackoftestsbreaksinnerquality 1.Viscosity 2.Immobility,Rigidity,Fragility 3.Unreadable 4.Complex
  61. simpledesignisgreattodetectsmells
  62. simpledesign 1.Alltestsrunandpass 2.Removeduplication 3.Removeopacity 4.Removecomplexity smells 1. Anytestssmells? 2.AnyDRYsmells? 3.Anyopacitysmells? 4.Anycomplexitysmells?
  63. TestSmells • Lackoftests • Testsarenotunitary • Setupistoocomplex • Unclearexercise • Morethanoneexpectationina test • Noexpectation • Toomanypaths
  64. DrySmells • Simpleduplication • Logicduplication • Duplicationofconstant • Alternativeclasseswithdifferentinterfaces
  65. OpacitySmells • Namenotfromdomain • Namenotexpressingintent • Featureenvy • Methoddoesmorethanone thing • Methodtoolong • Primitiveobsession • Commentsinthecode • MiddleMan
  66. ComplexitySmells • Unnecessaryelse • Unnecessaryif • Unnecessaryswitch • Toomanyargumentspassed • InappropriateIntimacy • Workinconstruction • Staticcontext
  67. usedesignpatternstorefactor
  68. creational?behavioural?structural?
  69. whatcanhappeninamethod?
  70. returnavalue modifystate printsomething throwanexception delegate {methods
  71. returnavalue modifystate printsomething throwanexception delegate {methods notthefinal behaviour
  72. returnavalue printsomething throwanexception delegate{methods weshouldprobably delegatethattoo
  73. returnavalue throwanexception delegate{methods
  74. designdelegationwithmocks
  75. startbydefiningbehaviour
  76. internallydelegatetoanothermethod
  77. Finally • Definenewrole • Extractcollaboratorsusingmocks • Movebehaviourdefinitiontonewcollaboratortest
  78. phpspec emergentdesign simpledesignandsmells designingcompositionwithmocks
  79. MarcelloDuarte Iworkhere Icontributehere Itweethere @_md
  80. Thankyou!
  81. QuestionsorComments? wanttolearnmore?bitly.com/inviqa-bdd-training @_md joind.in/8459
Advertisement