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

DDDの始め方

 DDDの始め方

DDDを始めるにあたって実施したことを実例を交えて紹介しています。
内容
- DDDとは何か
- なぜDDDをやるのか
- 実際にどうやって導入したか

Yamaki Hiroshi

July 19, 2017
Tweet

More Decks by Yamaki Hiroshi

Other Decks in Programming

Transcript

  1. σΟϨΫτϦߏ੒ Xxxx ├── App │ └── XxxxService.php ├── Domain │

    └── Xxxx.php ├── Infra │ └── XxxxRepository.php └── UI └── XxxxController.php
  2. Xxxx ├── App │ └── XxxxService.php ├── Domain │ └──

    Xxxx.php ├── Infra │ └── XxxxRepository.php └── UI └── XxxxController.php ˡ͜Ε͕ܾ·Δ Կ͕෼͔Δ͔ʁ
  3. class Period { public function shorten(DueDate $renewal_day) { if (!$this->canShorten($renewal_day))

    { throw new \OutOfRangeException("࣍ճߋ৽೔͕༗ޮͳൣғʹ͋Γ·ͤΜɻ"); } return new Period($this->startDay, $renewal_day); } public function canShorten(DueDate $renewal_day) { $candidate = $this->candidateShortenPeriod(); return $candidate->includes($renewal_day); } public function candidateShortenPeriod() { // ݄࣍ͷ1೔ʙݱࡏͷ࣍ճߋ৽೔·Ͱ͕୹ॖͷީิ return new static( new DueDate(new \DateTimeImmutable('first day of next month')), $this->renewalDay() ); } public function includes(DueDate $renewal_day) { return ($renewal_day == $this->startDay || $renewal_day->after($this- >startDay)) && ($renewal_day == $this->renewal_day || $renewal_day->before($this- >renewal_day)); } }