Slide 1

Slide 1 text

Aspect Oriented Architecture ytake

Slide 2

Slide 2 text

Aspect Oriented Programming • ΞεϖΫτࢦ޲Λཧղ͢ΔͨΊʹ͢΂͖͜ͱ͸ɺ
 ΦϒδΣΫτࢦ޲Λ·ͣ஌Δ͜ͱ • OOPʹ୅ΘΔ΋ͷͰ͸ͳ͘ɺॊೈੑΛ࣋ͨͤΔ
 ϓϩάϥϛϯάύϥμΠϜ • separation of concerns ʢؔ৺ࣄͷ෼཭ʣ

Slide 3

Slide 3 text

ϓϩάϥϜ͸Ͳ͏͋Δ΂͖͔ʁ • ίϯϙʔωϯτΛϕʔεʹγεςϜΛߏங͍ͯ͘͠Ұൠ తͳύλʔϯ • ΫϥεɺύοέʔδɺαʔϏεͳͲͷίϯϙʔωϯτʹ
 ཁٻΛׂΓ౰ͯͯߟ͑Δ • େମͷύλʔϯͰ͸ޮՌతʹίϯϙʔωϯτͱͯ͠࡞༻ • ޮՌతͰ͸ͳ͍ύλʔϯͱ͸ɺଞͷίϯϙʔωϯτʹ ӨڹΛ༩͑ͯ͠·͏΋ͷ͕෼཭Ͱ͖ͳ͍ύλʔϯͰ͋Γɺ ͜Ε͸େ͖ͳΞϓϦέʔγϣϯʹͳΕ͹ͳΔ΄Ͳ໰୊ ͱͳΓ·͢ɻ

Slide 4

Slide 4 text

ސ٬ը໘ ෦԰༧໿ ༧໿ ελοϑ check in check out ෦԰

Slide 5

Slide 5 text

ίϯϙʔωϯτͰղܾ͕Ͱ͖ͳ͍໰୊ • ϩΪϯάɺ෼ࢄॲཧɺτϥϯβΫγϣϯͳͲ
 ج൫తͳؔ৺ࣄ • ػೳཁ݅ʹ൐͏ɺϢʔεέʔεʹΑΔؔ৺ࣄ • ͜ΕΒΛԣஅతͳؔ৺ࣄͱݺͿ

Slide 6

Slide 6 text

ސ٬ Ϗδωε ෦԰ൢച ෦԰༧໿ ෦԰࡞੒

Slide 7

Slide 7 text

෦԰༧໿ • ۭ͖෦԰͕ͳ͚Ε͹ɺ
 γεςϜͰ͸ۭ͖෦԰͕ͳ͍ɺͱͯ͠ϝοηʔδग़ྗ • ۭ͖෦԰͕͋Ε͹ɺ
 γεςϜͰ͸༧໿Λ࡞੒

Slide 8

Slide 8 text

makeReservation ۭ͖෦԰ͳ͠ ༧໿࡞੒

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

෦԰༧໿(֦ு) • ೝՄ͞ΕͨϢʔβʔͷΈ͕༧໿Մೳͱ͢Δ • ۭ͖෦԰͕ͳ͍৔߹͸ɺΩϟϯηϧ଴ͪϦετ΁௥Ճ
 • ৼΔ෣͍Λ֦ு͢΂͖֦ுϙΠϯτΛࣝผ͢Δ • ௥ՃͷৼΔ෣͍Λఆٛ͢Δ

Slide 11

Slide 11 text

makeReservation ೝՄΤϥʔ ༧໿࡞੒ Ωϟϯηϧ଴ͪ΁

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

෦԰༧໿(֦ு) • ྫͰ͸ɺৼΔ෣͍Λ௥Ճ͍ͯ͠·͢ɻ • ։ൃऀ͔ΒΈΔͱ࣮૷ίʔυʹΑΔมߋ͸ͳ͘ɺ
 ֦ு͸෼཭͞Ε͍ͯΔͱݴ͑Δঢ়ଶʹ͋Δ • ΞεϖΫτ͸ෳ਺ͷૢ࡞Λ֦ு͢Δ͜ͱ͕Ͱ͖Δ

Slide 14

Slide 14 text

Laravel-Aspect
 (https://github.com/ytake/Laravel-Aspect)

Slide 15

Slide 15 text

͘͠Έ • ͲͷΫϥεͰͲΜͳ৚݅Ͱૢ࡞Λߦ͏͔
 (δϣΠϯτϙΠϯτɺϙΠϯτΧοτ) • ৚݅ʹ߹க͢ΔΫϥεΛίϯύΠϧ͠֎͔Β࣮ߦ
 (ίϯϙδγϣϯϝΧχζϜ) • ॲཧ࣮ߦ࣌ʹίϯςφ͕ίϯύΠϧࡁΈΫϥε΁ͱ
 ࠩ͠ସ͑Δ • ։ൃऀ͕ҙࣝ͠ͳ͍৔ॴͰॲཧΛ࣮ߦ͢Δ
 ίʔυ্ͷมߋ͸ΞϊςʔγϣϯͷΈ

Slide 16

Slide 16 text

ServiceProvider Aspect Factory Aspect Driver Compiler Container Annotation Driver

Slide 17

Slide 17 text

// contextual bind͔Ͳ͏͔ if (isset($this->app->contextual[$class])) { // $this->resolveContextualBindings($class, $compiledClass); } // ίϯύΠϧͨ͠Ϋϥε΁ͱೖΕସ͑Δ $this->app->bind($class, function ($app) use ($bind, $compiledClass) { $instance = $app->make($compiledClass); $instance->bindings = $bind->getBindings(); return $instance; });

Slide 18

Slide 18 text

σϑΥϧτͰ༻ҙ͞ΕͨΞϊςʔγϣϯ • @Cacheable (Ξϥ΢ϯυΞυόΠε)
 ࢦఆͨ͠ϝιουͷ໭Γ஋ΛΩϟογϡ
 ΩϟογϡΩʔɺ࣌ؒɺλάɺΩϟογϡ໊Λࢦఆ • @CachePut (Ξϥ΢ϯυΞυόΠε)
 ࢦఆͨ͠ϝιουͷ໭Γ஋ͷΩϟογϡΛ্ॻ͖
 ͳ͚Ε͹࡞੒ • @CacheEvict (ΞϑλʔΞυόΠε)
 ࢦఆͨ͠ϝιουͷ໭Γ஋ͷΩϟογϡΛ࡟আ

Slide 19

Slide 19 text

σϑΥϧτͰ༻ҙ͞ΕͨΞϊςʔγϣϯ • @Transactional (Ξϥ΢ϯυΞυόΠε)
 ΞϊςʔγϣϯΛهड़ͨ͠ϝιουͷॲཧத͸
 σʔλϕʔεͷτϥϯβΫγϣϯΛ࣮ߦ͢Δ • @Loggable (Ξϥ΢ϯυΞυόΠε)
 ΞϊʔςʔγϣϯΛهड़ͨ͠ϝιουͷ࣮ߦ࣌ؒɺ
 Ҿ਺ɺ໭Γ஋ΛϩΪϯά • @LogExceptions (ΞϑλʔΞυόΠε)
 ΞϊςʔγϣϯΛهड़ͨ͠ϝιουͰ
 ΤΫηϓγϣϯ͕εϩʔ͞Εͨ৔߹ʹҾ਺ΛϩΪϯά
 ͦͷ··ϋϯυϥʔ΁εϩʔ͢Δ

Slide 20

Slide 20 text

࣮ࡍʹ࢖ͬͨྫ • @Meta (ΞϑλʔΞυόΠε)
 Template΁metaλάΛૠೖ(canonical΍pageͳͲ) • @Cacel (ΞϑλʔΞυόΠε)
 ಛఆͷ৚݅ԼͰ༧໿ͷΩϟϯηϧΛߦ͏ • @PThread (Ξϥ΢ϯυΞυόΠε)
 ผεϨουͰ֘౰ͷϝιουΛ࣮ߦ͢Δ • @Queue (Ξϥ΢ϯυΞυόΠε)
 ΞϊςʔγϣϯͰࢦఆ͞ΕͨϝιουͷॲཧΛ
 QueueʹೖΕΔ

Slide 21

Slide 21 text

υϝΠϯϞσϧΛ࡞੒͠ɺ ԣஅతͳؔ৺͝ͱΛ୳ͯ͠ΈΑ͏ʂ Laravel-Aspect͕αϙʔτ͠·͢