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

アスペクト指向によるアプリケーション拡張

 アスペクト指向によるアプリケーション拡張

for phpカンファレンス関西 2016

yuuki takezawa

July 16, 2016
Tweet

More Decks by yuuki takezawa

Other Decks in Programming

Transcript

  1. Aspect Oriented Programming • OOPʹ୅ΘΔ΋ͷͰ͸ͳ͘ɺॊೈੑΛ࣋ͨͤΔ
 ϓϩάϥϛϯάύϥμΠϜ • separation of concerns

    ʢؔ৺ࣄͷ෼཭ʣ • ΞεϖΫτࢦ޲Λཧղ͢ΔͨΊʹ͢΂͖͜ͱ͸ɺ
 ΦϒδΣΫτࢦ޲Λ·ͣ஌Δ͜ͱ
  2. ΞυόΠε • before 
 δϣΠϯϙΠϯτൃੜલʹద༻ • after
 δϣΠϯϙΠϯτൃੜޙʹద༻ • around


    ݩͷॲཧΛஔ͖׵͑ͯ͠·͏৔߹΍ɺ
 ಛఆͷॲཧͰڬΈࠐΉ ᷖճॲཧ(go around)
  3. /** * @param $id * * @return mixed * @throws

    \Exception */ public function makeReservation($id) { if ($this->reserve->getQuantity($id)) { return $this->reserve->createReservation($id); } throw new \NoStockException(); }
  4. /** * @param $id * @WaitingList * @return mixed *

    @throws \Exception */ public function makeReservation($id) { if ($this->reserve->getQuantity($id)) { return $this->reserve->createReservation($id); } throw new \NoStockException(); }
  5. /** * @param MethodInvoke $invoke * * @return object *

    @throws \Exception */ public function __invoke(MethodInvoke $invoke) { try { $result = $invoke->proceed(); }catch(\NoRoomException $e) { // Ωϟϯηϧ଴ͪϦετ΁ͷ௥Ճॲཧ } return $result; }
  6. ঎඼ߪೖɾ༧໿γεςϜ • ސ٬͸঎඼Λ༧໿Ͱ͖Δ • ελοϑ͸঎඼ొ࿥ɺऔΓѻ͍ఀࢭΛૢ࡞Ͱ͖Δ • ؅ཧऀ͸ඪ४Ձ֨ͱظؒݶఆηʔϧͷઃఆ͕Ͱ͖Δ • ϝϯόʔձһ͸ɺϙΠϯτΛஷΊͯࢧ෷͍ʹར༻Ͱ͖Δ •

    ήετɺ๏ਓɺϝϯόʔձһͱ͍͏ސ٬λΠϓΛऔΓѻ͏ • γεςϜ͸web͔Βར༻Ͱ͖Δඞཁ͕͋Δ • γεςϜ͸RDBMSΛར༻ͯ͠σʔλΛอ࣋͢Δ • ؂ࠪͷͨΊɺ͢΂ͯͷॲཧ͸ϩάʹग़ྗ͢Δ
 etc…