Specking Interactors with PHPSpec and YOLO (DDD) at PHPConference Argentina 2013

1,463 views

Published on

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,463
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
3
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Specking Interactors with PHPSpec and YOLO (DDD) at PHPConference Argentina 2013

  1. 1. Specking Interactors with PHPSpec and YOLO Toward the scorners he is scornful,     but to the humble he gives favor. ~ Proverbs 3:34 Friday, October 4, 13
  2. 2. Take control of your project and live a simpler life Toward the scorners he is scornful,     but to the humble he gives favor. ~ Proverbs 3:34 Friday, October 4, 13
  3. 3. Framework != Domain Friday, October 4, 13
  4. 4. Test First Friday, October 4, 13
  5. 5. Domain Domain Friday, October 4, 13
  6. 6. Implementations are Details Friday, October 4, 13
  7. 7. http://www.austinchronicle.com/binary/d294/SS.Hook._leftsideonly_.jpg Friday, October 4, 13
  8. 8. http://www.collider.com/wp-content/uploads/Inception-movie-poster-2.jpg Friday, October 4, 13
  9. 9. http://static.guim.co.uk/sys-images/Film/Pix/pictures/2008/06/06/matrix460.jpg Friday, October 4, 13
  10. 10. Signs of Inception Friday, October 4, 13
  11. 11. Our Framework The Best Friday, October 4, 13
  12. 12. Our Practices The Best Friday, October 4, 13
  13. 13. Our Community never makes mistakes Friday, October 4, 13
  14. 14. Framework is convenient Friday, October 4, 13
  15. 15. But we are not solving The Problem Friday, October 4, 13
  16. 16. Friday, October 4, 13
  17. 17. Friday, October 4, 13
  18. 18. Friday, October 4, 13
  19. 19. Friday, October 4, 13
  20. 20. Domain Friday, October 4, 13
  21. 21. Domain Expert Friday, October 4, 13
  22. 22. BDD Friday, October 4, 13
  23. 23. BDD Tools Behat, PhpSpec Friday, October 4, 13
  24. 24. but DDD is for Large Systems ... Friday, October 4, 13
  25. 25. Friday, October 4, 13
  26. 26. show me how... Friday, October 4, 13
  27. 27. Friday, October 4, 13
  28. 28. Problem: some don’t want to pay for certification exams, so let’s build a community site for those exams. Friday, October 4, 13
  29. 29. Before we jump into the sauce: Find a qualified examiner, could be a real educator if not then try to become one Friday, October 4, 13
  30. 30. Spec First ↝ BDD + DDD Feature: student can take an exam   Scenario: student takes an exam Given student starts an exam And student is presented with a question When student answers to question ... Then student ends exam and gets graded Friday, October 4, 13
  31. 31. Modeling BDD Scenario feature DSL Learning Process Friday, October 4, 13
  32. 32. Modeling repository BDD Scenario feature DSL Support BDD entity value object service interactor (use case) port Learning Process Friday, October 4, 13
  33. 33. Modeling Exam Repository Attempt Repository Exam Attempt service Grader Converter interactor (use case) ShowAll Exams Grade Attempt repository BDD Scenario feature DSL Support BDD entity BDD Spec value object port Learning Process Friday, October 4, 13 Question
  34. 34. Modeling Exam Repository Attempt Repository Exam Attempt service Grader Converter interactor (use case) ShowAll Exams Grade Attempt repository BDD Scenario feature DSL Support BDD entity BDD Spec value object port Learning Process Friday, October 4, 13 Question DDD Breaking and Fixing Specs
  35. 35. Modeling Exam Repository Attempt Repository Exam Attempt service Grader Converter interactor (use case) ShowAll Exams Grade Attempt repository BDD Scenario feature DSL Support BDD DDD Refactoring Behavior entity BDD Spec value object port Learning Process Friday, October 4, 13 Question DDD Breaking and Fixing Specs
  36. 36. Learning Process Friday, October 4, 13
  37. 37. Folder Structure To convey: - inversion of dependencies - make dependencies explicit - domain and infrastructure separation - bounded context separation Friday, October 4, 13
  38. 38. ~ !"" #   #   !"" #   #   #   #   #   #   #   #   #   #   #   tree -L 6 features !"" student_takes_exam.feature $"" teacher_builds_exam.feature spec $"" Simulator !"" Domain #   !"" Model #   #   $"" Exam #   #   !"" AttemptSpec.php #   #   !"" ExamSpec.php #   #   !"" OptionSpec.php #   #   $"" QuestionSpec.php #   !"" Port #   #   !"" AnswerSpec.php #   #   !"" ExamSpec.php Friday, October 4, 13 Notice these are specs!
  39. 39. ~ !"" #   #   !"" #   #   #   #   #   #   #   #   #   #   #   tree -L 6 features !"" student_takes_exam.feature $"" teacher_builds_exam.feature spec $"" Simulator !"" Domain #   !"" Model #   #   $"" Exam #   #   !"" AttemptSpec.php #   #   !"" ExamSpec.php #   #   !"" OptionSpec.php #   #   $"" QuestionSpec.php #   !"" Port #   #   !"" AnswerSpec.php #   #   !"" ExamSpec.php Friday, October 4, 13
  40. 40. ~ !"" #   #   !"" #   #   #   #   #   #   #   #   #   #   #   tree -L 6 features !"" student_takes_exam.feature $"" teacher_builds_exam.feature spec $"" Simulator !"" Domain #   !"" Model #   #   $"" Exam #   #   !"" AttemptSpec.php #   #   !"" ExamSpec.php #   #   !"" OptionSpec.php #   #   $"" QuestionSpec.php #   !"" Port #   #   !"" AnswerSpec.php #   #   !"" ExamSpec.php Friday, October 4, 13
  41. 41. ~ tree -L ... #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   Friday, October 4, 13 6 !"" #   #   #   !"" #   #   #   !"" #   $"" Port !"" AnswerSpec.php !"" ExamSpec.php $"" ExamsSpec.php Services !"" ExamsConverterSpec.php !"" GraderSpec.php $"" PrototypeManagerSpec.php Support $"" StudentHelperSpec.php UseCase !"" GradesAttemptSpec.php
  42. 42. ~ tree -L ... #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   Friday, October 4, 13 6 !"" #   #   #   !"" #   #   #   !"" #   $"" Port !"" AnswerSpec.php !"" ExamSpec.php $"" ExamsSpec.php Services !"" ExamsConverterSpec.php !"" GraderSpec.php $"" PrototypeManagerSpec.php Support $"" StudentHelperSpec.php UseCase !"" GradesAttemptSpec.php
  43. 43. ~ tree -L ... #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   Friday, October 4, 13 6 !"" #   #   #   !"" #   #   #   !"" #   $"" Port !"" AnswerSpec.php !"" ExamSpec.php $"" ExamsSpec.php Services !"" ExamsConverterSpec.php !"" GraderSpec.php $"" PrototypeManagerSpec.php Support $"" StudentHelperSpec.php UseCase !"" GradesAttemptSpec.php
  44. 44. ~ tree -L 6 ... #   #   #   #   #   #   #   #   #   Friday, October 4, 13 $"" Infrastructure !"" Cilex #   !"" Command #   #   $"" ShowAllExamsCommand.php #   !"" Console #   #   $"" Runner.php #   !"" Provider #   #   $"" SimulatorServiceProvider.php #   $"" config.yml
  45. 45. ~ tree -L 6 ... #   | #   #   #   #   #   #   #   #   #   #   #   #   #   Friday, October 4, 13 $"" Infrastructure ... !"" Persistence #   !"" Doctrine #   #   $"" OrmExamRepository.php #   !"" InMemoryAttemptRepository.php #   !"" InMemoryExamRepository.php #   $"" PDO #   $"" PdoExamRepository.php !"" Symfony #   $"" Bundle #   $"" SimulatorBundle $"" Yolo $"" Controller $"" ExamController.php
  46. 46. ~ tree -L 6 ... #   | #   #   #   #   #   #   #   #   #   #   #   #   #   Friday, October 4, 13 $"" Infrastructure ... !"" Persistence #   !"" Doctrine #   #   $"" OrmExamRepository.php #   !"" InMemoryAttemptRepository.php #   !"" InMemoryExamRepository.php #   $"" PDO #   $"" PdoExamRepository.php !"" Symfony #   $"" Bundle #   $"" SimulatorBundle $"" Yolo $"" Controller $"" ExamController.php
  47. 47. ~ tree -L 6 ... #   | #   #   #   #   #   #   #   #   #   #   #   #   #   Friday, October 4, 13 $"" Infrastructure ... !"" Persistence #   !"" Doctrine #   #   $"" OrmExamRepository.php #   !"" InMemoryAttemptRepository.php #   !"" InMemoryExamRepository.php #   $"" PDO #   $"" PdoExamRepository.php !"" Symfony #   $"" Bundle #   $"" SimulatorBundle $"" Yolo $"" Controller $"" ExamController.php
  48. 48. What if I ask you which classes implement the features? Friday, October 4, 13
  49. 49. Folder Structure ~ tree -L ... #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   6 !"" #   #   #   !"" #   #   #   !"" #   $"" Port !"" AnswerSpec.php !"" ExamSpec.php $"" ExamsSpec.php Services !"" ExamsConverterSpec.php !"" GraderSpec.php $"" PrototypeManagerSpec.php Support $"" StudentHelperSpec.php UseCase !"" GradesAttemptSpec.php This bring us back to interactors/use cases Friday, October 4, 13
  50. 50. Friday, October 4, 13
  51. 51. Friday, October 4, 13
  52. 52. Domain ↝ Domain - intention - expressive - explicit Friday, October 4, 13
  53. 53. Domain ↝ Domain Friday, October 4, 13
  54. 54. Domain ↝ Domain Friday, October 4, 13
  55. 55. Show what you did :) Friday, October 4, 13
  56. 56. "repositories": [ { "type": "vcs", "url": "git@github.com:cordoval/ExamSimulator" } ], "require": { "igorw/yolo": "dev-master", "cordoval/exam-simulator": "dev-master" }, Friday, October 4, 13
  57. 57. ~ php bin/console exams:show - yolo - part I - yolo - part II All exams displayed Friday, October 4, 13
  58. 58. http:// craftitonline.com END Friday, October 4, 13

×