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

今日から書けるリーダブルコード

Avatar for Daiki Nojiri Daiki Nojiri
February 14, 2020

 今日から書けるリーダブルコード

Avatar for Daiki Nojiri

Daiki Nojiri

February 14, 2020
Tweet

More Decks by Daiki Nojiri

Other Decks in Programming

Transcript

  1. ݟͨ໨͕੔͍ͬͯΕ͹ಡΈ΍͍͢ʁ function isNull($array) { foreach($array as $v) { if (is_null($v))

    { return false; } } return true; } Πϯσϯτ͕͖Ε͍ͳίʔυ CSSͰ΋͍͍͔΋ function isNull($array) { foreach ($array as $v) { if (is_null($v)) { return false; } } return true; }
  2. ௕͘ͳ͍͍͔ͬͯΒӅͯ͠͠·͏ if (split(':', $line)[0] === 'root') { // } $username

    = split(':', $line)[0]; if ($username === 'root') { // } ˜
  3. if (split(':', $line)[0] === 'root') { // } ˜ //

    ίϩϯͷࠨଆΛநग़͢Δ $username = split(':', $line)[0]; if ($username === root) { // } ඞཁͳΒίϝϯτ΋
  4. ⁞໊લΛΧϥϑϧʹ͢Δ BGUFS HFU)UNM QPTU  ɹ%#ʹอଘ͞Ε͍ͯΔ)5.-Λऔͬͯ͘Δ GFUDI)UNM VSM  ɹࢦఆͨ͠63-͔Β)5.-Λऔͬͯ͘Δ

    HFOFSBUF)UNM UFNQMBUF  ɹςϯϓϨʔτ͔Β)5.-Λੜ੒͢Δ CVJME)UNM QBSUT  ɹ෦඼Λ૊Έ߹Θͤͯ)5.-Λੜ੒͢Δ
  5.  ૣ͘SFUVSO͢Δ CFGPSF if (auth(‘admin’)->check() || (auth()->check() && auth()->user()->isPurchased($item) ) )

    { if ($item->raw()—>exists()) { return Storage::download($item->raw); } } return redirect()->back(); ݖݶνΣοΫ ϑΝΠϧͷଘࡏ֬ೝ
  6.  ૣ͘SFUVSO͢Δ CFGPSF if (auth(‘admin’)->check() || (auth()->check() && auth()->user()->isPurchased($item) ) )

    { if ($item->raw()—>exists()) { return Storage::download($item->raw); } } return redirect()->back(); JGจ͕ωετ͍ͯ͠Δ
  7.  ૣ͘SFUVSO͢Δ BGUFS if ($item->raw()—>doesNotExists()) { return redirect()->back(); } if (auth(‘admin’)->check()

    || (auth()->check() && auth()->user()->isPurchased($item) ) ) { return Storage::download($item->raw); } return redirect()->back();
  8.  ૣ͘SFUVSO͢Δ BGUFS if ($item->raw()—>doesNotExists()) { return redirect()->back(); } if (auth(‘admin’)->check()

    || (auth()->check() && auth()->user()->isPurchased($item) ) ) { return Storage::download($item->raw); } return redirect()->back(); ϑΝΠϧͷଘࡏ֬ೝ ݖݶνΣοΫ ϑΝΠϧ͕ͳ͍࣌఺ͰSFUVSO͢Ε͹ɼ ݖݶνΣοΫͰϑΝΠϧͷ͜ͱΛؾʹ͠ͳ͍͍ͯ͘
  9. ⁠JGจΛ෼ׂ͢Δ BGUFS if ($item->raw()—>doesNotExists()) { return redirect()->back(); } if (auth(‘admin’)->check()

    || (auth()->check() && auth()->user()->isPurchased($item)) ) { return Storage::download($item->raw); } return redirect()->back(); BENJOͱVTFSΛҰ౓ʹνΣοΫ͠Α͏ͱ ͢Δ͔Βͪ͝Όͪ͝Όͯ͠͠·͏
  10. ⁠JGจΛ෼ׂ͢Δ BGUFS if ($item->raw()—>doesNotExists()) { return redirect()->back(); } if (auth(‘admin’)->check())

    { return Storage::download($item->raw); } if (auth()->check() && auth()->user()->isPurchased($item)) { return Storage::download($item->raw); } return redirect()->back(); BENJOͷݖݶνΣοΫ VTFSͷݖݶνΣοΫ
  11. ⁠JGจΛ෼ׂ͢Δ BGUFS if ($item->raw()—>doesNotExists()) { return redirect()->back(); } if (auth(‘admin’)->check())

    { return Storage::download($item->raw); } if (auth()->check() && auth()->user()->isPurchased($item)) { return Storage::download($item->raw); } return redirect()->back(); ϑΝΠϧͷଘࡏ֬ೝ BENJOͷݖݶνΣοΫ VTFSͷݖݶνΣοΫ
  12. ӳ୯ޠͷόϦΤʔγϣϯΛ૿΍ͯ͠ΈΔ ෺ཧ໊ ࿦ཧ໊ OFXTCPEZ ͓஌Βͤ಺༰ BVUIPSTEFUBJM ஶऀʹ͍ͭͯ ৄࡉ BVUIPSTEFTDSJQUJPO ஶऀʹ͍ͭͯ

    આ໌ TFSJFTPWFSWJFX ֓ཁ DMJFOUTSFNBSL උߟ ӳ୯ޠΛ஌͓ͬͯ͘ ඞཁ͕͋Δ͚Ͳɺ ෺ཧ໊Λݟ͚ͨͩͰ ஋Λ૝૾Ͱ͖Δ ⁞໊લΛΧϥϑϧʹ͢Δ BGUFS