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

本当にあった怖いPHPコード7選

 本当にあった怖いPHPコード7選

今まで仕事で携わってきたPHPでの開発において、可読性、保守性が明らかに低かったコードの例を話し、リファクタリングする場合はどうするかなどを説明します。
例えば、メソッドの引数が7個以上ある。変数名が解読不能。if文のネストが7つ以上あるなどです。

02886e95c50822b9aa2552da1e518491?s=128

Takayuki

April 09, 2022
Tweet

More Decks by Takayuki

Other Decks in Programming

Transcript

  1. ླ໦޹೭

  2. ࣗݾ঺հɾձࣾ঺հ ා͍ίʔυͱ͸ʁ ຊ౰ʹ͋ͬͨා͍1)1ίʔυબ

  3. Copyright Re:Build.inc All Rights Reserved. ର৅ऀʹ͍ͭͯ 0 1)1ͷجૅ஌͕ࣝ͋Δ ॳڃऀʙதڃऀ޲͚

  4. ࣗݾ঺հɾձࣾ঺հ

  5. Copyright Re:Build.inc All Rights Reserved. ࣗݾ঺հ 1 ◆໊લ ླ໦ ޹೭(Suzuki

    Takayuki) ※ಉ੏ಉ໊ଟͯ͘ࠔͬͯ·͢ɻɻɻ ◆ࣗݾ঺հ ɾ1990೥ੜ·Εɻ ɾΤϯδχΞˠϑϦʔϥϯεˠԭೄͰىۀ ɾPHPΧϯϑΝϨϯεԭೄ࣮ߦҕһ௕ ◆झຯ ίεϓϨɺԻָϥΠϒɺϚϥιϯେձʹग़Δɺ໺ٿ؍ઓ BDD(Ϗʔνۦಈ։ൃ)
  6. Copyright Re:Build.inc All Rights Reserved. ࣗݾ঺հ 1

  7. Copyright Re:Build.inc All Rights Reserved. ձࣾ঺հ 1 ◆ձ໊ࣾ גࣜձࣾRe:Build ◆ॅॴ

    ԭೄݝಹ೼ࢢٱໜ஍2-2-2 λΠϜεϏϧ ◆ࣄۀ಺༰ ɾࣗࣾWEBαʔϏεͷاըɾ։ൃɻ ɾडୗ։ൃ ɾϓϩάϥϛϯάεΫʔϧ ◆ࣾһ 12໊ ΤϯδχΞืूͯ͠·͢ʂʂʂ
  8. ා͍ίʔυͱ͸ʁ

  9. Copyright Re:Build.inc All Rights Reserved. ͜ͷൃදʹ͓͚Δා͍ίʔυͱ͸ʁ - Մಡੑɺอकੑ͕໌Β͔ʹ௿͍ίʔυͳͲΛࢦ͠·͢ɻ - ྫ͑͹ɺϝιουͷॲཧ͕෼͔Γʹ͍͘ɻม਺໊͕ղಡෆೳ

    ͳͲͰ͢ɻ 2
  10. ຊ౰ʹ͋ͬͨා͍1)1ίʔυબ ※࣮ࡍͷίʔυΛΞϨϯδ͠ ͯɺՍۭͷίʔυΛྫʹग़ͯ͠ ͍·͢ɻ

  11. Copyright Re:Build.inc All Rights Reserved. ຊ౰ʹ͋ͬͨා͍PHPίʔυ7બ 3 ᶃϝιουͷҾ਺͕7ݸҎ্͋Γɺม਺໊͸ΞϧϑΝϕοτΛฒ΂͚ͨͩ ൃڰͦ͠͏ʂʂ

  12. Copyright Re:Build.inc All Rights Reserved. ຊ౰ʹ͋ͬͨා͍PHPίʔυ7બ 3 ᶃϝιουͷҾ਺͕7ݸҎ্͋Γɺม਺໊͸ΞϧϑΝϕοτΛฒ΂͚ͨͩ ݺͼग़͠ݩΛݟͯ΋ Կͷม਺͔Θ͔Βͳ

    ͍…ɻ ม਺໊͸Θ͔Γ΍͢ ໊͍લʹ͠·͠ΐ͏
  13. Copyright Re:Build.inc All Rights Reserved. ຊ౰ʹ͋ͬͨා͍PHPίʔυ7બ ᶄifจͷωετ͕6ݸҎ্͋Δ ૣظϦλʔϯΛ͠· ͠ΐ͏ 3

  14. Copyright Re:Build.inc All Rights Reserved. ຊ౰ʹ͋ͬͨා͍PHPίʔυ7બ ᶅม਺໊͕Θ͔Γʹ͍͘ ɾҙຯ͕Θ͔Βͳ͍਺ࣈ͸ೖΕͳ͍ ɾෆཁͳ୯ޠ͸ഉআ͢Δ ɾ೔ຊޠΛϩʔϚࣈʹͨ͠ม਺໊͸

    NG ɾ഑ྻ΍ίϨΫγϣϯ͸ෳ਺ܗʹ͢ Δ ɾ඼ࢺΛҙࣝ͢Δ 3
  15. Copyright Re:Build.inc All Rights Reserved. ຊ౰ʹ͋ͬͨා͍PHPίʔυ7બ ᶆҰͭͷΞΫγϣϯϝιουʹཪͰ̏ͭΤϯυϙΠϯτ͕ଘࡏ͍ͯ͠Δ cinemaͷbladeʹ ϨεϙϯεΛฦ͢ apiͱͯ͠JSONͷ

    ϨεϙϯεΛฦ͢ eventͷbladeʹ ϨεϙϯεΛฦ͢ ҰͭͷΞΫγϣϯϝιο υʹ͸ҰͭͷΤϯυϙΠ ϯτʹ͢Δ 3 Controller Ϋϥε /event ?mode=apiMode ?event=cinema ?event=
  16. Copyright Re:Build.inc All Rights Reserved. ຊ౰ʹ͋ͬͨා͍PHPίʔυ7બ ᶇίϝϯτΞ΢τ஍ࠈ ͍ͭ͜ͷίϝϯτΞ ΢τΛ෮׆ͤ͞Δͷ ͔ରԠظݶΛܾΊΔ

    3
  17. Copyright Re:Build.inc All Rights Reserved. ຊ౰ʹ͋ͬͨා͍PHPίʔυ7બ ᶈϚδοΫφϯόʔ஍ࠈ ఆ਺Λఆٛͯ͠ɺ֤਺ࣈ ͕ͲͷΑ͏ͳҙຯͳͷ͔ Θ͔ΔΑ͏ʹ͢Δ

    3
  18. Copyright Re:Build.inc All Rights Reserved. ຊ౰ʹ͋ͬͨා͍PHPίʔυ7બ ᶉҰͭͷϑΝΠϧʹ̎ͭΫϥε͕ఆٛ͞Ε͍ͯΔ ಛผͳཧ༝͕ͳ͚Ε͹ɺͲ ͜ʹΫϥε͕͋Δͷ͔Θ͔ Γʹ͍͘ͷͰɺ̍ϑΝΠϧ

    ʹ̍Ϋϥεͱ͢Δ 3
  19. Copyright Re:Build.inc All Rights Reserved. ·ͱΊ - Ͳ͏͍͏ίʔυ͕ٕज़తෛ࠴ʹͳΔ͔ཧղͯ͠ɺଞͷਓ͕ ཧղ͠΍͍͢ίʔυΛॻ͖·͠ΐ͏ʂ -

    ίʔυϨϏϡʔΛೖΕͯଐਓԽ͸ආ͚·͠ΐ͏ɻ - ίʔυΛҾ͖ܧ͍ͩਓ͕ٽ͖·͢…
  20. Copyright Re:Build.inc All Rights Reserved. ࢀߟจݙ - Ϧʔμϒϧίʔυ

  21. Copyright Re:Build.inc All Rights Reserved. ࠂ஌ PHPΧϯϑΝϨϯε2022ΛՆࠒʹ։࠵༧ఆͰ͢ʂ ※৽ܕίϩφ΢ΠϧεͷӨڹͰ೔ఔ͸લޙ͢ΔՄೳੑ͕͋Γ·͢ɻ