Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Specing interactors con BDD PHPSpec2 y YOLO framework

cordoval
October 04, 2013

Specing interactors con BDD PHPSpec2 y YOLO framework

DDD inside :)

cordoval

October 04, 2013
Tweet

More Decks by cordoval

Other Decks in Technology

Transcript

  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. 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. Problem: some don’t want to pay for certification exams, so

    let’s build a community site for those exams. Friday, October 4, 13
  4. 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
  5. 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
  6. Modeling feature DSL entity service repository interactor (use case) port

    value object BDD Scenario Support BDD Learning Process Friday, October 4, 13
  7. Modeling feature DSL entity service repository interactor (use case) port

    value object Exam Repository Attempt Repository Attempt Question Exam Grader Converter ShowAll Exams Grade Attempt BDD Scenario BDD Spec Support BDD Learning Process Friday, October 4, 13
  8. Modeling feature DSL entity service repository interactor (use case) port

    value object Exam Repository Attempt Repository Attempt Question Exam Grader Converter ShowAll Exams Grade Attempt BDD Scenario BDD Spec Support BDD DDD Breaking and Fixing Specs Learning Process Friday, October 4, 13
  9. Modeling feature DSL entity service repository interactor (use case) port

    value object Exam Repository Attempt Repository Attempt Question Exam Grader Converter ShowAll Exams Grade Attempt BDD Scenario BDD Spec Support BDD DDD Refactoring Behavior DDD Breaking and Fixing Specs Learning Process Friday, October 4, 13
  10. Folder Structure To convey: - inversion of dependencies - make

    dependencies explicit - domain and infrastructure separation - bounded context separation Friday, October 4, 13
  11. ~ 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 Notice these are specs! Friday, October 4, 13
  12. ~ 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
  13. ~ 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
  14. ~ tree -L 6 ... # # !"" Port #

    # # !"" AnswerSpec.php # # # !"" ExamSpec.php # # # $"" ExamsSpec.php # # !"" Services # # # !"" ExamsConverterSpec.php # # # !"" GraderSpec.php # # # $"" PrototypeManagerSpec.php # # !"" Support # # # $"" StudentHelperSpec.php # # $"" UseCase # # !"" GradesAttemptSpec.php Friday, October 4, 13
  15. ~ tree -L 6 ... # # !"" Port #

    # # !"" AnswerSpec.php # # # !"" ExamSpec.php # # # $"" ExamsSpec.php # # !"" Services # # # !"" ExamsConverterSpec.php # # # !"" GraderSpec.php # # # $"" PrototypeManagerSpec.php # # !"" Support # # # $"" StudentHelperSpec.php # # $"" UseCase # # !"" GradesAttemptSpec.php Friday, October 4, 13
  16. ~ tree -L 6 ... # # !"" Port #

    # # !"" AnswerSpec.php # # # !"" ExamSpec.php # # # $"" ExamsSpec.php # # !"" Services # # # !"" ExamsConverterSpec.php # # # !"" GraderSpec.php # # # $"" PrototypeManagerSpec.php # # !"" Support # # # $"" StudentHelperSpec.php # # $"" UseCase # # !"" GradesAttemptSpec.php Friday, October 4, 13
  17. ~ tree -L 6 ... # $"" Infrastructure # !""

    Cilex # # !"" Command # # # $"" ShowAllExamsCommand.php # # !"" Console # # # $"" Runner.php # # !"" Provider # # # $"" SimulatorServiceProvider.php # # $"" config.yml Friday, October 4, 13
  18. ~ tree -L 6 ... # $"" Infrastructure | ...

    # !"" Persistence # # !"" Doctrine # # # $"" OrmExamRepository.php # # !"" InMemoryAttemptRepository.php # # !"" InMemoryExamRepository.php # # $"" PDO # # $"" PdoExamRepository.php # !"" Symfony # # $"" Bundle # # $"" SimulatorBundle # $"" Yolo # $"" Controller # $"" ExamController.php Friday, October 4, 13
  19. ~ tree -L 6 ... # $"" Infrastructure | ...

    # !"" Persistence # # !"" Doctrine # # # $"" OrmExamRepository.php # # !"" InMemoryAttemptRepository.php # # !"" InMemoryExamRepository.php # # $"" PDO # # $"" PdoExamRepository.php # !"" Symfony # # $"" Bundle # # $"" SimulatorBundle # $"" Yolo # $"" Controller # $"" ExamController.php Friday, October 4, 13
  20. ~ tree -L 6 ... # $"" Infrastructure | ...

    # !"" Persistence # # !"" Doctrine # # # $"" OrmExamRepository.php # # !"" InMemoryAttemptRepository.php # # !"" InMemoryExamRepository.php # # $"" PDO # # $"" PdoExamRepository.php # !"" Symfony # # $"" Bundle # # $"" SimulatorBundle # $"" Yolo # $"" Controller # $"" ExamController.php Friday, October 4, 13
  21. 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
  22. "repositories": [ { "type": "vcs", "url": "[email protected]:cordoval/ExamSimulator" } ], "require":

    { "igorw/yolo": "dev-master", "cordoval/exam-simulator": "dev-master" }, Friday, October 4, 13
  23. ~ php bin/console exams:show - yolo - part I -

    yolo - part II All exams displayed Friday, October 4, 13