Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
今日から書けるリーダブルコード
Search
Daiki Nojiri
February 14, 2020
Programming
0
330
今日から書けるリーダブルコード
Daiki Nojiri
February 14, 2020
Tweet
Share
More Decks by Daiki Nojiri
See All by Daiki Nojiri
イメージで理解するgRPC
nojiri1098
0
250
GitのCLI操作を楽にするためにエイリアスを作った話
nojiri1098
0
230
Other Decks in Programming
See All in Programming
とにかくAWS GameDay!AWSは世界の共通言語! / Anyway, AWS GameDay! AWS is the world's lingua franca!
seike460
PRO
1
860
聞き手から登壇者へ: RubyKaigi2024 LTでの初挑戦が 教えてくれた、可能性の星
mikik0
1
130
Content Security Policy入門 セキュリティ設定と 違反レポートのはじめ方 / Introduction to Content Security Policy Getting Started with Security Configuration and Violation Reporting
uskey512
1
530
Better Code Design in PHP
afilina
PRO
0
120
GitHub Actionsのキャッシュと手を挙げることの大切さとそれに必要なこと
satoshi256kbyte
5
430
Amazon Qを使ってIaCを触ろう!
maruto
0
400
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
110
as(型アサーション)を書く前にできること
marokanatani
9
2.6k
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
100
最新TCAキャッチアップ
0si43
0
140
Jakarta EE meets AI
ivargrimstad
0
130
Remix on Hono on Cloudflare Workers
yusukebe
1
280
Featured
See All Featured
We Have a Design System, Now What?
morganepeng
50
7.2k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
Art, The Web, and Tiny UX
lynnandtonic
297
20k
GitHub's CSS Performance
jonrohan
1030
460k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
A Tale of Four Properties
chriscoyier
156
23k
Visualization
eitanlees
145
15k
The Language of Interfaces
destraynor
154
24k
Building Your Own Lightsaber
phodgson
103
6.1k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.2k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
Why Our Code Smells
bkeepers
PRO
334
57k
Transcript
Ϧʔμϒϧίʔυ ΑΓྑ͍ίʔυΛॻͨ͘Ίͷ࣮ફతͳςΫχοΫ
None
ࠓͷΰʔϧ ɾϦʔμϒϧίʔυͬͯͳʹʁ ɾͳΜͰϦʔμϒϧίʔυΛॻ͘ͷʁ ɾͲ͏ͬͯϦʔμϒϧίʔυΛॻ͘ͷʁ
Ϧʔμϒϧίʔυͬͯͳʹʁ
Ϧʔμϒϧίʔυ ˜ SFBEBCMFDPEF ˜ ಡΈ͍͢ίʔυ
ಡΈ͍͢ίʔυͬͯ ͲΜͳίʔυͩͱࢥ͍·͔͢ʁ
ݟ͕͍ͨͬͯΕಡΈ͍͢ʁ 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; }
Ϧʔμϒϧίʔυͱ ଞͷਓ͕࠷࣌ؒͰ ཧղͰ͖Δίʔυ
Ϧʔμϒϧίʔυͱ ଞͷਓ͕࠷࣌ؒͰ ཧղͰ͖Δίʔυ
Ϧʔμϒϧίʔυͱ ଞͷਓ͕࠷࣌ؒͰ ཧղͰ͖Δίʔυ
͍͚Ͳɺ͙͢ʹཧղͰ͖ͳ͍ if (split(':', $line)[0] === 'root') { // }
͘ͳ͍͍͔ͬͯΒӅͯ͠͠·͏ if (split(':', $line)[0] === 'root') { // } $username
= split(':', $line)[0]; if ($username === 'root') { // } ˜
if (split(':', $line)[0] === 'root') { // } ˜ //
ίϩϯͷࠨଆΛநग़͢Δ $username = split(':', $line)[0]; if ($username === root) { // } ඞཁͳΒίϝϯτ
ͳΜͰϦʔμϒϧίʔυΛॻ͘ͷʁ
ͳΜͰಡΈ͍͢ίʔυΛ ॻ͍ͨ΄͏͕͍͍ͱࢥ͍·͔͢ʁ
Ϧʔμϒϧίʔυͱ ଞͷਓ͕࠷࣌ؒͰ ཧղͰ͖Δίʔυ
։ൃ͕εϜʔζʹਐΉ ಡΈ͍͢ίʔυͳΒʜ ɾղऍʹ໎Θͳ͍ɺޡղ͕ੜ·Εͳ͍ ɾಈ࡞ͷཧղ͕ૣ͘ͳΔ ɾҾ͖ܧָ͕͗ ɾಥવϓϩδΣΫτʹΞαΠϯ͞Εͯେৎ ಡΈʹ͍͘ίʔυͩͱʜ ɾೝ͕͍͕ࣝͪ͘͏ɺޡղ͕ੜ͡Δ ɾಡΈͨ͘ͳ͘ͳΔ ɾετϨεΛײ͡Δ
ɾͪΐͬͱͨ͠ػೳՃʹ͕͔͔࣌ؒΔ
։ൃ͕εϜʔζʹਐΉ ಡΈ͍͢ίʔυͳΒʜ ɾղऍʹ໎Θͳ͍ɺޡղ͕ੜ·Εͳ͍ ɾಈ࡞ͷཧղ͕ૣ͘ͳΔ ɾҾ͖ܧָ͕͗ ɾಥવϓϩδΣΫτʹΞαΠϯ͞Εͯେৎ ಡΈʹ͍͘ίʔυͩͱʜ ɾೝ͕͍͕ࣝͪ͘͏ɺޡղ͕ੜ͡Δ ɾಡΈͨ͘ͳ͘ͳΔ ɾετϨεΛײ͡Δ
ɾͪΐͬͱͨ͠ػೳՃʹ͕͔͔࣌ؒΔ ಡΈ͍͢ίʔυΛॻ͜͏ʂ
Ϧʔμϒϧίʔυͬͯ Ͳ͏ͬͯॻ͘ͷʁ
͜͜·Ͱͷ෮श ಡΈ͍͢ίʔυͬͯͳʹʁ ˠଞͷਓ͕࠷࣌ؒͰཧղͰ͖Δίʔυ ͳΜͰಡΈ͍͢ίʔυΛॻ͘ͷʁ ˠ։ൃ͕εϜʔζʹͳΔ͔Β ɹ։ൃָ͕ʹͳΔ͔Β
Ͱɺ۩ମతʹͲ͏ͬͯॻ͘ͷʁ
ૣ͘SFUVSO͢Δ ⁞ม໊ΛΧϥϑϧʹ͢Δ JGจΛׂ͢Δ ͙͢ʹਅࣅͰ͖ΔͭͷςΫχοΫ
⁞໊લΛΧϥϑϧʹ͢Δ
⁞໊લΛΧϥϑϧʹ͢Δ CFGPSF ͳΜͰಉ͡ಈࢺʹ͕ͪ͠ ɾHFU'JMF ɾHFU+TPO ɾHFU)UNM ɾHFU%BUB ɾHFU1BHF ɾHFU6TFS/BNF ɾHFU1BSBNT
ɾHFU4FBSDI2VFSZ
͍ΖΜͳ୯ޠ͕͋Γ·͢ HFU ͍ۙͱ͜Ζ͔Βऔͬͯ͘Δ GFUDI ԕ͍ͱ͜Ζ͔Βऔͬͯ͘Δ NBLF ൺֱతখ͞ͳͷΛ࡞Δ ࡐྉΛՃ͢Δ CVJME ൺֱతେ͖ͳͷΛ࡞Δ
ΈཱͯΔ HFOFSBUF Կ͔Λมͯ͠࡞Γग़͢ DSFBUF Կͳ͍ͱ͜Ζʹ৽͘͠࡞Δ
⁞໊લΛΧϥϑϧʹ͢Δ BGUFS HFU)UNM QPTU ɹ%#ʹอଘ͞Ε͍ͯΔ)5.-Λऔͬͯ͘Δ GFUDI)UNM VSM ɹࢦఆͨ͠63-͔Β)5.-Λऔͬͯ͘Δ
HFOFSBUF)UNM UFNQMBUF ɹςϯϓϨʔτ͔Β)5.-Λੜ͢Δ CVJME)UNM QBSUT ɹ෦ΛΈ߹Θͤͯ)5.-Λੜ͢Δ
ૣ͘SFUVSO͢Δ
ૣ͘SFUVSO͢Δ CFGPSF if (auth(‘admin’)->check() || (auth()->check() && auth()->user()->isPurchased($item) ) )
{ if ($item->raw()—>exists()) { return Storage::download($item->raw); } } return redirect()->back(); ݖݶνΣοΫ ϑΝΠϧͷଘࡏ֬ೝ
ૣ͘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จ͕ωετ͍ͯ͠Δ
ૣ͘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͢Δ 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͢Εɼ ݖݶνΣοΫͰϑΝΠϧͷ͜ͱΛؾʹ͠ͳ͍͍ͯ͘
JGจΛׂ͢Δ
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ΛҰʹνΣοΫ͠Α͏ͱ ͢Δ͔Βͪ͝Όͪ͝Όͯ͠͠·͏
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ͷݖݶνΣοΫ
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ͷݖݶνΣοΫ
ࠓͷ·ͱΊ ಡΈ͍͢ίʔυͬͯͳʹʁ ˠଞͷਓ͕࠷࣌ؒͰཧղͰ͖Δίʔυ ͳΜͰಡΈ͍͢ίʔυΛॻ͘ͷʁ ˠ։ൃ͕εϜʔζʹͳΔ͔Β Ͳ͏ͬͯಡΈ͍͢ίʔυΛॻ͘ͷʁ ˠ͍ΖΜͳςΫχοΫ͕͋ͬͯɺ ɹʰϦʔμϒϧίʔυʱͰͨ͘͞Μհ͞Εͯ ɹ͍Δ
͓·͚ ϘπҊ ͔ͤͬ͘ͳͷͰ͚ͱ͖·͢
⁞໊લΛΧϥϑϧʹ͢Δ CFGPSF %#ͷΧϥϜ໊Λྫʹ ཧ໊ ཧ໊ OFXTEFUBJM ͓Βͤ༰ BVUIPSTEFUBJM ஶऀʹ͍ͭͯ TFSJFTEFTDSJQUJPO
֓ཁ DMJFOUTEFTDSJQUJPO උߟ
%#ͷΧϥϜ໊Λྫʹ ཧ໊ ཧ໊ OFXTEFUBJM ͓Βͤ༰ BVUIPSTEFUBJM ஶऀʹ͍ͭͯ TFSJFTEFTDSJQUJPO ֓ཁ DMJFOUTEFTDSJQUJPO
උߟ EFUBJMৄࡉɺEFTDSJQUJPOઆ໌ ⁞໊લΛΧϥϑϧʹ͢Δ CFGPSF
%#ͷΧϥϜ໊Λྫʹ ཧ໊ ཧ໊ OFXTEFUBJM ͓Βͤ༰ BVUIPSTEFUBJM ஶऀʹ͍ͭͯ TFSJFTEFTDSJQUJPO ֓ཁ DMJFOUTEFTDSJQUJPO
උߟ ཧ໊͕ҧ͏ͷʹཧ໊ಉ͡ ⁞໊લΛΧϥϑϧʹ͢Δ CFGPSF
%#ͷΧϥϜ໊Λྫʹ ཧ໊ ཧ໊ OFXTEFUBJM ͓Βͤ༰ BVUIPSTEFUBJM ஶऀʹ͍ͭͯ TFSJFTEFTDSJQUJPO ֓ཁ DMJFOUTEFTDSJQUJPO
උߟ ཧ໊͕ҧ͏ͷʹཧ໊ಉ͡ ⁞໊લΛΧϥϑϧʹ͢Δ CFGPSF
%#ͷΧϥϜ໊Λྫʹ ཧ໊ ཧ໊ OFXTEFUBJM ͓Βͤ༰ BVUIPSTEFUBJM ஶऀʹ͍ͭͯ TFSJFTEFTDSJQUJPO ֓ཁ DMJFOUTEFTDSJQUJPO
උߟ ύοͱݟ͚ͨͩͰΘ͔Βͳ͍ ⁞໊લΛΧϥϑϧʹ͢Δ CFGPSF
⁞໊લΛΧϥϑϧʹ͢Δ BGUFS ӳ୯ޠͷόϦΤʔγϣϯΛ૿ͯ͠ΈΔ ཧ໊ ཧ໊ OFXTCPEZ ͓Βͤ༰ BVUIPSTEFUBJM ஶऀʹ͍ͭͯ ৄࡉ
BVUIPSTEFTDSJQUJPO ஶऀʹ͍ͭͯ આ໌ TFSJFTPWFSWJFX ֓ཁ DMJFOUTSFNBSL උߟ
ӳ୯ޠͷόϦΤʔγϣϯΛ૿ͯ͠ΈΔ ཧ໊ ཧ໊ OFXTCPEZ ͓Βͤ༰ BVUIPSTEFUBJM ஶऀʹ͍ͭͯ ৄࡉ BVUIPSTEFTDSJQUJPO ஶऀʹ͍ͭͯ
આ໌ TFSJFTPWFSWJFX ֓ཁ DMJFOUTSFNBSL උߟ ӳ୯ޠΛ͓ͬͯ͘ ඞཁ͕͋Δ͚Ͳɺ ཧ໊Λݟ͚ͨͩͰ Λ૾Ͱ͖Δ ⁞໊લΛΧϥϑϧʹ͢Δ BGUFS